From 5e17431283001e1f730d0d5fdd08ce706bfc31a6 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 9 Nov 2022 09:57:50 +0530 Subject: [PATCH 1/2] Fix null pointer exception sentry#5606 --- lib/services/remote_sync_service.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/services/remote_sync_service.dart b/lib/services/remote_sync_service.dart index 214e70c08..84e77dbea 100644 --- a/lib/services/remote_sync_service.dart +++ b/lib/services/remote_sync_service.dart @@ -580,6 +580,8 @@ class RemoteSyncService { File existingFile; if (remoteDiff.generatedID != null) { // Case [1] Check and clear local cache when uploadedFile already exist + // Note: Existing file can be null here if it's replaced by the time we + // reach here existingFile = await _db.getFile(remoteDiff.generatedID); if (_shouldClearCache(remoteDiff, existingFile)) { needsGalleryReload = true; @@ -692,10 +694,10 @@ class RemoteSyncService { } bool _shouldClearCache(File remoteFile, File existingFile) { - if (remoteFile.hash != null && existingFile.hash != null) { + if (remoteFile.hash != null && existingFile?.hash != null) { return remoteFile.hash != existingFile.hash; } - return remoteFile.updationTime != (existingFile.updationTime ?? 0); + return remoteFile.updationTime != (existingFile?.updationTime ?? 0); } bool _shouldReloadHomeGallery(File remoteFile, File existingFile) { From 3c48f2de5655bc4fc10d5a80d6b448d5a41d9d24 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:05:02 +0530 Subject: [PATCH 2/2] Ignore conflicting insert during deviceCover update sentry#4338 --- lib/db/device_files_db.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/db/device_files_db.dart b/lib/db/device_files_db.dart index 4f8b01882..55758b960 100644 --- a/lib/db/device_files_db.dart +++ b/lib/db/device_files_db.dart @@ -209,6 +209,7 @@ extension DeviceFiles on FilesDB { "cover_id": localID, "should_backup": shouldBackup ? _sqlBoolTrue : _sqlBoolFalse }, + conflictAlgorithm: ConflictAlgorithm.ignore, ); } }