minor fixes
This commit is contained in:
parent
0689a3541b
commit
1833a8cde5
2 changed files with 15 additions and 5 deletions
|
@ -652,8 +652,6 @@ class AvesEntry {
|
||||||
static int compareByDate(AvesEntry a, AvesEntry b) {
|
static int compareByDate(AvesEntry a, AvesEntry b) {
|
||||||
var c = (b.bestDate ?? _epoch).compareTo(a.bestDate ?? _epoch);
|
var c = (b.bestDate ?? _epoch).compareTo(a.bestDate ?? _epoch);
|
||||||
if (c != 0) return c;
|
if (c != 0) return c;
|
||||||
c = (b.dateModifiedSecs ?? 0).compareTo(a.dateModifiedSecs ?? 0);
|
return compareByName(b, a);
|
||||||
if (c != 0) return c;
|
|
||||||
return -compareByName(a, b);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ class MediaStoreSource extends CollectionSource {
|
||||||
final knownPathById = Map.fromEntries(allEntries.map((entry) => MapEntry(entry.contentId, entry.path)));
|
final knownPathById = Map.fromEntries(allEntries.map((entry) => MapEntry(entry.contentId, entry.path)));
|
||||||
final movedContentIds = (await MediaStoreService.checkObsoletePaths(knownPathById)).toSet();
|
final movedContentIds = (await MediaStoreService.checkObsoletePaths(knownPathById)).toSet();
|
||||||
movedContentIds.forEach((contentId) {
|
movedContentIds.forEach((contentId) {
|
||||||
|
// make obsolete by resetting its modified date
|
||||||
knownDateById[contentId] = 0;
|
knownDateById[contentId] = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -94,7 +95,13 @@ class MediaStoreSource extends CollectionSource {
|
||||||
debugPrint('$runtimeType refresh loaded ${allNewEntries.length} new entries, elapsed=${stopwatch.elapsed}');
|
debugPrint('$runtimeType refresh loaded ${allNewEntries.length} new entries, elapsed=${stopwatch.elapsed}');
|
||||||
|
|
||||||
await metadataDb.saveEntries(allNewEntries); // 700ms for 5500 entries
|
await metadataDb.saveEntries(allNewEntries); // 700ms for 5500 entries
|
||||||
invalidateAlbumFilterSummary(entries: allNewEntries);
|
|
||||||
|
if (allNewEntries.isNotEmpty) {
|
||||||
|
// new entries include existing entries with obsolete paths
|
||||||
|
// so directories may be added, but also removed or simply have their content summary changed
|
||||||
|
invalidateAlbumFilterSummary();
|
||||||
|
updateDirectories();
|
||||||
|
}
|
||||||
|
|
||||||
final analytics = FirebaseAnalytics();
|
final analytics = FirebaseAnalytics();
|
||||||
unawaited(analytics.setUserProperty(name: 'local_item_count', value: (ceilBy(allEntries.length, 3)).toString()));
|
unawaited(analytics.setUserProperty(name: 'local_item_count', value: (ceilBy(allEntries.length, 3)).toString()));
|
||||||
|
@ -140,6 +147,7 @@ class MediaStoreSource extends CollectionSource {
|
||||||
// fetch new entries
|
// fetch new entries
|
||||||
final tempUris = <String>{};
|
final tempUris = <String>{};
|
||||||
final newEntries = <AvesEntry>{};
|
final newEntries = <AvesEntry>{};
|
||||||
|
final existingDirectories = <String>{};
|
||||||
for (final kv in uriByContentId.entries) {
|
for (final kv in uriByContentId.entries) {
|
||||||
final contentId = kv.key;
|
final contentId = kv.key;
|
||||||
final uri = kv.value;
|
final uri = kv.value;
|
||||||
|
@ -151,6 +159,9 @@ class MediaStoreSource extends CollectionSource {
|
||||||
final volume = androidFileUtils.getStorageVolume(sourceEntry.path);
|
final volume = androidFileUtils.getStorageVolume(sourceEntry.path);
|
||||||
if (volume != null) {
|
if (volume != null) {
|
||||||
newEntries.add(sourceEntry);
|
newEntries.add(sourceEntry);
|
||||||
|
if (existingEntry != null) {
|
||||||
|
existingDirectories.add(existingEntry.directory);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
debugPrint('$runtimeType refreshUris entry=$sourceEntry is not located on a known storage volume. Will retry soon...');
|
debugPrint('$runtimeType refreshUris entry=$sourceEntry is not located on a known storage volume. Will retry soon...');
|
||||||
tempUris.add(uri);
|
tempUris.add(uri);
|
||||||
|
@ -160,9 +171,10 @@ class MediaStoreSource extends CollectionSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newEntries.isNotEmpty) {
|
if (newEntries.isNotEmpty) {
|
||||||
|
invalidateAlbumFilterSummary(directories: existingDirectories);
|
||||||
addEntries(newEntries);
|
addEntries(newEntries);
|
||||||
await metadataDb.saveEntries(newEntries);
|
await metadataDb.saveEntries(newEntries);
|
||||||
invalidateAlbumFilterSummary(entries: newEntries);
|
cleanEmptyAlbums(existingDirectories);
|
||||||
|
|
||||||
stateNotifier.value = SourceState.cataloguing;
|
stateNotifier.value = SourceState.cataloguing;
|
||||||
await catalogEntries();
|
await catalogEntries();
|
||||||
|
|
Loading…
Reference in a new issue