media store monitoring: fixed external removal
This commit is contained in:
parent
accfb2c57b
commit
c05b646ddd
7 changed files with 19 additions and 17 deletions
|
@ -95,7 +95,6 @@ object PermissionManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
Log.d(LOG_TAG, "getInaccessibleDirectories dirPaths=$dirPaths -> inaccessibleDirs=$inaccessibleDirs")
|
||||
return inaccessibleDirs
|
||||
}
|
||||
|
||||
|
@ -124,7 +123,6 @@ object PermissionManager {
|
|||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
accessibleDirs.add(StorageUtils.getPrimaryVolumePath(context))
|
||||
}
|
||||
Log.d(LOG_TAG, "getAccessibleDirs accessibleDirs=$accessibleDirs")
|
||||
return accessibleDirs
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class CollectionLens with ChangeNotifier, CollectionActivityMixin, CollectionSel
|
|||
_subscriptions.add(source.eventBus.on<EntryMovedEvent>().listen((e) => _refresh()));
|
||||
_subscriptions.add(source.eventBus.on<CatalogMetadataChangedEvent>().listen((e) => _refresh()));
|
||||
_subscriptions.add(source.eventBus.on<AddressMetadataChangedEvent>().listen((e) {
|
||||
if (filters.any((filter) => filter is LocationFilter)) {
|
||||
if (this.filters.any((filter) => filter is LocationFilter)) {
|
||||
_refresh();
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -71,7 +71,8 @@ abstract class CollectionSource with SourceBase, AlbumMixin, LocationMixin, TagM
|
|||
eventBus.fire(EntryAddedEvent());
|
||||
}
|
||||
|
||||
void removeEntries(List<AvesEntry> entries) {
|
||||
void removeEntries(Set<AvesEntry> entries) {
|
||||
if (entries.isEmpty) return;
|
||||
entries.forEach((entry) => entry.removeFromFavourites());
|
||||
_rawEntries.removeWhere(entries.contains);
|
||||
cleanEmptyAlbums(entries.map((entry) => entry.directory).toSet());
|
||||
|
|
|
@ -123,8 +123,9 @@ class MediaStoreSource extends CollectionSource {
|
|||
|
||||
// clean up obsolete entries
|
||||
final obsoleteContentIds = (await ImageFileService.getObsoleteEntries(uriByContentId.keys.toList())).toSet();
|
||||
uriByContentId.removeWhere((contentId, _) => obsoleteContentIds.contains(contentId));
|
||||
metadataDb.removeIds(obsoleteContentIds, updateFavourites: true);
|
||||
obsoleteContentIds.forEach(uriByContentId.remove);
|
||||
final obsoleteEntries = rawEntries.where((e) => obsoleteContentIds.contains(e.contentId)).toSet();
|
||||
removeEntries(obsoleteEntries);
|
||||
|
||||
// fetch new entries
|
||||
final newEntries = <AvesEntry>[];
|
||||
|
@ -132,14 +133,16 @@ class MediaStoreSource extends CollectionSource {
|
|||
final contentId = kv.key;
|
||||
final uri = kv.value;
|
||||
final sourceEntry = await ImageFileService.getEntry(uri, null);
|
||||
final existingEntry = rawEntries.firstWhere((entry) => entry.contentId == contentId, orElse: () => null);
|
||||
if (existingEntry == null || sourceEntry.dateModifiedSecs > existingEntry.dateModifiedSecs) {
|
||||
final volume = androidFileUtils.getStorageVolume(sourceEntry.path);
|
||||
if (volume != null) {
|
||||
newEntries.add(sourceEntry);
|
||||
} else {
|
||||
debugPrint('$runtimeType refreshUris entry=$sourceEntry is not located on a known storage volume. Will retry soon...');
|
||||
tempUris.add(uri);
|
||||
if (sourceEntry != null) {
|
||||
final existingEntry = rawEntries.firstWhere((entry) => entry.contentId == contentId, orElse: () => null);
|
||||
if (existingEntry == null || sourceEntry.dateModifiedSecs > existingEntry.dateModifiedSecs) {
|
||||
final volume = androidFileUtils.getStorageVolume(sourceEntry.path);
|
||||
if (volume != null) {
|
||||
newEntries.add(sourceEntry);
|
||||
} else {
|
||||
debugPrint('$runtimeType refreshUris entry=$sourceEntry is not located on a known storage volume. Will retry soon...');
|
||||
tempUris.add(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware
|
|||
showFeedback(context, 'Failed to delete ${Intl.plural(count, one: '$count item', other: '$count items')}');
|
||||
}
|
||||
if (deletedCount > 0) {
|
||||
source.removeEntries(selection.where((e) => deletedUris.contains(e.uri)).toList());
|
||||
source.removeEntries(selection.where((e) => deletedUris.contains(e.uri)).toSet());
|
||||
}
|
||||
collection.clearSelection();
|
||||
collection.browse();
|
||||
|
|
|
@ -92,7 +92,7 @@ class AlbumChipActionDelegate extends ChipActionDelegate with FeedbackMixin, Per
|
|||
showFeedback(context, 'Failed to delete ${Intl.plural(count, one: '$count item', other: '$count items')}');
|
||||
}
|
||||
if (deletedCount > 0) {
|
||||
source.removeEntries(selection.where((e) => deletedUris.contains(e.uri)).toList());
|
||||
source.removeEntries(selection.where((e) => deletedUris.contains(e.uri)).toSet());
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
@ -141,7 +141,7 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMix
|
|||
showFeedback(context, 'Failed');
|
||||
} else {
|
||||
if (hasCollection) {
|
||||
collection.source.removeEntries([entry]);
|
||||
collection.source.removeEntries({entry});
|
||||
}
|
||||
EntryDeletedNotification(entry).dispatch(context);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue