Merge pull request #628 from ente-io/null_handling

Fixes couple of bugs reported on sentry
This commit is contained in:
Neeraj Gupta 2022-11-09 15:17:24 +05:30 committed by GitHub
commit 0eb0c106d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -209,6 +209,7 @@ extension DeviceFiles on FilesDB {
"cover_id": localID,
"should_backup": shouldBackup ? _sqlBoolTrue : _sqlBoolFalse
},
conflictAlgorithm: ConflictAlgorithm.ignore,
);
}
}

View file

@ -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) {