Fix unsupported files returned from scan account bloc

This commit is contained in:
Ming Ming 2022-10-30 17:20:24 +08:00
parent 9759f172db
commit 72ebbfdd08

View file

@ -204,8 +204,7 @@ class ScanAccountDirBloc
"[_onEventQuery] Elapsed time (_queryOffline): ${stopwatch.elapsedMilliseconds}ms, ${cacheFiles.length} files"); "[_onEventQuery] Elapsed time (_queryOffline): ${stopwatch.elapsedMilliseconds}ms, ${cacheFiles.length} files");
if (!hasContent) { if (!hasContent) {
// show something instantly on first load // show something instantly on first load
emit(ScanAccountDirBlocLoading( emit(ScanAccountDirBlocLoading(cacheFiles));
cacheFiles.where((f) => file_util.isSupportedFormat(f)).toList()));
} }
stopwatch.reset(); stopwatch.reset();
@ -214,8 +213,7 @@ class ScanAccountDirBloc
hasUpdate = await _syncOnline(ev); hasUpdate = await _syncOnline(ev);
} catch (e, stackTrace) { } catch (e, stackTrace) {
_log.shout("[_onEventQuery] Exception while request", e, stackTrace); _log.shout("[_onEventQuery] Exception while request", e, stackTrace);
emit(ScanAccountDirBlocFailure( emit(ScanAccountDirBlocFailure(cacheFiles, e));
cacheFiles.where((f) => file_util.isSupportedFormat(f)).toList(), e));
return; return;
} }
_log.info( _log.info(
@ -434,7 +432,8 @@ class ScanAccountDirBloc
if (!isShareDirIncluded) { if (!isShareDirIncluded) {
_log.info("[_queryOffline] Explicitly scanning share folder"); _log.info("[_queryOffline] Explicitly scanning share folder");
try { try {
files.addAll(await Ls(_c.fileRepoLocal)(account, shareDir)); final raw = await Ls(_c.fileRepoLocal)(account, shareDir);
files.addAll(raw.where((f) => file_util.isSupportedFormat(f)));
} on CacheNotFoundException catch (_) { } on CacheNotFoundException catch (_) {
// normal when there's no cache // normal when there's no cache
} catch (e, stackTrace) { } catch (e, stackTrace) {