Logging improvements: 2/n
This commit is contained in:
parent
9faeb511db
commit
9f72614ed2
14 changed files with 65 additions and 20 deletions
|
@ -1,3 +1,3 @@
|
|||
class Event {
|
||||
String get reason => toString();
|
||||
String get reason => '$runtimeType';
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class FilesUpdatedEvent extends Event {
|
|||
});
|
||||
|
||||
@override
|
||||
String get reason => '${toString()}{type: ${type.name}, "via": $source}';
|
||||
String get reason => '$runtimeType{type: ${type.name}, "via": $source}';
|
||||
}
|
||||
|
||||
enum EventType {
|
||||
|
|
|
@ -6,5 +6,5 @@ class ForceReloadHomeGalleryEvent extends Event {
|
|||
ForceReloadHomeGalleryEvent(this.message);
|
||||
|
||||
@override
|
||||
String get reason => 'ForceReloadHomeGalleryEvent - $message';
|
||||
String get reason => '$runtimeType - $message';
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:photos/events/files_updated_event.dart';
|
||||
|
||||
class LocalPhotosUpdatedEvent extends FilesUpdatedEvent {
|
||||
LocalPhotosUpdatedEvent(updatedFiles, {type, source})
|
||||
LocalPhotosUpdatedEvent(updatedFiles, {type, required source})
|
||||
: super(
|
||||
updatedFiles,
|
||||
type: type ?? EventType.addedOrUpdated,
|
||||
|
|
|
@ -103,7 +103,12 @@ class CollectionsService {
|
|||
if (collection.isDeleted) {
|
||||
await _filesDB.deleteCollection(collection.id);
|
||||
await setCollectionSyncTime(collection.id, null);
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent(List<File>.empty()));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(
|
||||
List<File>.empty(),
|
||||
source: "syncCollectionDeleted",
|
||||
),
|
||||
);
|
||||
}
|
||||
// remove reference for incoming collections when unshared/deleted
|
||||
if (collection.isDeleted && ownerID != collection?.owner?.id) {
|
||||
|
@ -876,7 +881,7 @@ class CollectionsService {
|
|||
await _filesDB.removeFromCollection(collectionID, params["fileIDs"]);
|
||||
Bus.instance
|
||||
.fire(CollectionUpdatedEvent(collectionID, files, "removeFrom"));
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent(files));
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent(files, source: "removeFrom"));
|
||||
RemoteSyncService.instance.sync(silently: true).ignore();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,11 +37,21 @@ class FileMagicService {
|
|||
if (visibility == visibilityVisible) {
|
||||
// Force reload home gallery to pull in the now unarchived files
|
||||
Bus.instance.fire(ForceReloadHomeGalleryEvent("unarchivedFiles"));
|
||||
Bus.instance
|
||||
.fire(LocalPhotosUpdatedEvent(files, type: EventType.unarchived));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(
|
||||
files,
|
||||
type: EventType.unarchived,
|
||||
source: "vizChange",
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Bus.instance
|
||||
.fire(LocalPhotosUpdatedEvent(files, type: EventType.archived));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(
|
||||
files,
|
||||
type: EventType.archived,
|
||||
source: "vizChange",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,10 @@ class LocalSyncService {
|
|||
);
|
||||
if (hasAnyMappingChanged || hasUnsyncedFiles) {
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(localDiffResult.uniqueLocalFiles),
|
||||
LocalPhotosUpdatedEvent(
|
||||
localDiffResult.uniqueLocalFiles,
|
||||
source: "syncAllChange",
|
||||
),
|
||||
);
|
||||
}
|
||||
_logger.info("syncAll took ${stopwatch.elapsed.inMilliseconds}ms ");
|
||||
|
@ -359,7 +362,9 @@ class LocalSyncService {
|
|||
conflictAlgorithm: ConflictAlgorithm.ignore,
|
||||
);
|
||||
_logger.info("Inserted " + files.length.toString() + " files.");
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent(allFiles));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(allFiles, source: "loadedPhoto"),
|
||||
);
|
||||
}
|
||||
await _prefs.setInt(kDbUpdationTimeKey, toTime);
|
||||
}
|
||||
|
|
|
@ -354,7 +354,9 @@ class RemoteSyncService {
|
|||
// remove all collectionIDs which are still marked for backup
|
||||
oldCollectionIDsForAutoSync.removeAll(newCollectionIDsForAutoSync);
|
||||
await removeFilesQueuedForUpload(oldCollectionIDsForAutoSync.toList());
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent(<File>[]));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(<File>[], source: "deviceFolderSync"),
|
||||
);
|
||||
Bus.instance.fire(BackupFoldersUpdatedEvent());
|
||||
}
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
|
|||
}
|
||||
newFile.generatedID = await FilesDB.instance.insert(newFile);
|
||||
await LocalSyncService.instance.trackEditedFile(newFile);
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent([newFile]));
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent([newFile], source: "editSave"));
|
||||
SyncService.instance.sync();
|
||||
showToast(context, "Edits saved");
|
||||
_logger.info("Original file " + widget.originalFile.toString());
|
||||
|
|
|
@ -458,7 +458,12 @@ class FadingAppBarState extends State<FadingAppBar> {
|
|||
await IgnoredFilesService.instance.cacheAndInsert([ignoreVideoFile]);
|
||||
file.localID = savedAsset.id;
|
||||
await FilesDB.instance.insert(file);
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent([file]));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(
|
||||
[file],
|
||||
source: "download",
|
||||
),
|
||||
);
|
||||
} else if (!downloadLivePhotoOnDroid && savedAsset == null) {
|
||||
_logger.severe('Failed to save assert of type $type');
|
||||
}
|
||||
|
|
|
@ -176,6 +176,7 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
|
|||
LocalPhotosUpdatedEvent(
|
||||
[widget.file],
|
||||
type: EventType.deletedFromDevice,
|
||||
source: "thumbFileDeleted",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -183,6 +183,7 @@ class _ZoomableImageState extends State<ZoomableImage>
|
|||
LocalPhotosUpdatedEvent(
|
||||
[_photo],
|
||||
type: EventType.deletedFromDevice,
|
||||
source: "zoomPreview",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ Future<void> deleteFilesFromEverywhere(
|
|||
LocalPhotosUpdatedEvent(
|
||||
deletedFiles,
|
||||
type: EventType.deletedFromEverywhere,
|
||||
source: "deleteFilesEverywhere",
|
||||
),
|
||||
);
|
||||
if (hasLocalOnlyFiles && Platform.isAndroid) {
|
||||
|
@ -182,8 +183,13 @@ Future<void> deleteFilesFromRemoteOnly(
|
|||
),
|
||||
);
|
||||
}
|
||||
Bus.instance
|
||||
.fire(LocalPhotosUpdatedEvent(files, type: EventType.deletedFromRemote));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(
|
||||
files,
|
||||
type: EventType.deletedFromRemote,
|
||||
source: "deleteFromRemoteOnly",
|
||||
),
|
||||
);
|
||||
SyncService.instance.sync();
|
||||
await dialog.hide();
|
||||
RemoteSyncService.instance.sync(silently: true);
|
||||
|
@ -245,6 +251,7 @@ Future<void> deleteFilesOnDeviceOnly(
|
|||
LocalPhotosUpdatedEvent(
|
||||
deletedFiles,
|
||||
type: EventType.deletedFromDevice,
|
||||
source: "deleteFilesOnDeviceOnly",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -343,7 +350,9 @@ Future<bool> deleteLocalFiles(
|
|||
final deletedFiles = await FilesDB.instance.getLocalFiles(deletedIDs);
|
||||
await FilesDB.instance.deleteLocalFiles(deletedIDs);
|
||||
_logger.info(deletedFiles.length.toString() + " files deleted locally");
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent(deletedFiles));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(deletedFiles, source: "deleteLocal"),
|
||||
);
|
||||
return true;
|
||||
} else {
|
||||
showToast(context, "Could not free up space");
|
||||
|
|
|
@ -448,7 +448,12 @@ class FileUploader {
|
|||
await FilesDB.instance.update(remoteFile);
|
||||
}
|
||||
if (!_isBackground) {
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent([remoteFile]));
|
||||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(
|
||||
[remoteFile],
|
||||
source: "downloadComplete",
|
||||
),
|
||||
);
|
||||
}
|
||||
_logger.info("File upload complete for " + remoteFile.toString());
|
||||
uploadCompleted = true;
|
||||
|
@ -533,7 +538,8 @@ class FileUploader {
|
|||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(
|
||||
[fileToUpload],
|
||||
type: EventType.deletedFromEverywhere, //
|
||||
type: EventType.deletedFromEverywhere,
|
||||
source: "sameLocalSameCollection", //
|
||||
),
|
||||
);
|
||||
return Tuple2(true, sameLocalSameCollection);
|
||||
|
@ -562,6 +568,7 @@ class FileUploader {
|
|||
Bus.instance.fire(
|
||||
LocalPhotosUpdatedEvent(
|
||||
[fileToUpload],
|
||||
source: "alreadyUploadedInSameCollection",
|
||||
type: EventType.deletedFromEverywhere, //
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue