Skip to content

Commit ef0a4ff

Browse files
authored
fix(storage,windows): Windows list()/listAll() now throw unimplemented instead of returning misleading empty results (#18449)
1 parent 6f22596 commit ef0a4ff

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

packages/firebase_storage/firebase_storage/windows/firebase_storage_plugin.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -470,22 +470,18 @@ void FirebaseStoragePlugin::ReferenceList(
470470
const InternalStorageReference& reference,
471471
const InternalListOptions& options,
472472
std::function<void(ErrorOr<InternalListResult> reply)> result) {
473-
// C++ doesn't support list yet
474-
flutter::EncodableList items = flutter::EncodableList();
475-
flutter::EncodableList prefixs = flutter::EncodableList();
476-
InternalListResult pigeon_result = InternalListResult(items, prefixs);
477-
result(pigeon_result);
473+
result(FlutterError(
474+
"unimplemented",
475+
"Listing files is not supported by the Firebase C++ SDK on Windows."));
478476
}
479477

480478
void FirebaseStoragePlugin::ReferenceListAll(
481479
const InternalStorageFirebaseApp& app,
482480
const InternalStorageReference& reference,
483481
std::function<void(ErrorOr<InternalListResult> reply)> result) {
484-
// C++ doesn't support listAll yet
485-
flutter::EncodableList items = flutter::EncodableList();
486-
flutter::EncodableList prefixs = flutter::EncodableList();
487-
InternalListResult pigeon_result = InternalListResult(items, prefixs);
488-
result(pigeon_result);
482+
result(FlutterError(
483+
"unimplemented",
484+
"Listing files is not supported by the Firebase C++ SDK on Windows."));
489485
}
490486

491487
void FirebaseStoragePlugin::ReferenceGetData(

tests/integration_test/firebase_storage/reference_e2e.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,28 @@ void setupReferenceTests() {
224224
skip: defaultTargetPlatform == TargetPlatform.windows,
225225
);
226226

227+
test(
228+
'list operations report that they are unsupported on Windows',
229+
() async {
230+
final Reference ref = storage.ref('flutter-tests/list');
231+
final unsupportedError = isA<FirebaseException>()
232+
.having((error) => error.code, 'code', 'unimplemented')
233+
.having(
234+
(error) => error.message,
235+
'message',
236+
'Listing files is not supported by the Firebase C++ SDK on '
237+
'Windows.',
238+
);
239+
240+
await expectLater(
241+
ref.list(const ListOptions(maxResults: 25)),
242+
throwsA(unsupportedError),
243+
);
244+
await expectLater(ref.listAll(), throwsA(unsupportedError));
245+
},
246+
skip: defaultTargetPlatform != TargetPlatform.windows,
247+
);
248+
227249
test(
228250
'listAll',
229251
() async {

0 commit comments

Comments
 (0)