Fix duplicate file issue
This commit is contained in:
parent
aba132058d
commit
43c9fa37cd
3 changed files with 15 additions and 19 deletions
|
@ -174,21 +174,15 @@ class FilesDB {
|
|||
return _convertToFiles(results);
|
||||
}
|
||||
|
||||
Future<File> getMatchingFile(
|
||||
String localID,
|
||||
String title,
|
||||
String deviceFolder,
|
||||
int creationTime,
|
||||
int modificationTime,
|
||||
String encryptedKey,
|
||||
String iv,
|
||||
Future<File> getMatchingFile(String localID, String title,
|
||||
String deviceFolder, int creationTime, int modificationTime,
|
||||
{String alternateTitle}) async {
|
||||
final db = await instance.database;
|
||||
final rows = await db.query(
|
||||
table,
|
||||
where: '''$columnLocalID=? AND ($columnTitle=? OR $columnTitle=?) AND
|
||||
$columnDeviceFolder=? AND $columnCreationTime=? AND
|
||||
$columnModificationTime=? AND $columnEncryptedPassword AND $columnEncryptedPasswordIV''',
|
||||
$columnModificationTime=?''',
|
||||
whereArgs: [
|
||||
localID,
|
||||
title,
|
||||
|
@ -196,8 +190,6 @@ class FilesDB {
|
|||
deviceFolder,
|
||||
creationTime,
|
||||
modificationTime,
|
||||
encryptedKey,
|
||||
iv,
|
||||
],
|
||||
);
|
||||
if (rows.isNotEmpty) {
|
||||
|
|
|
@ -60,8 +60,6 @@ class FaceSearchManager {
|
|||
file.deviceFolder,
|
||||
file.creationTime,
|
||||
file.modificationTime,
|
||||
file.encryptedPassword,
|
||||
file.encryptedPasswordIV,
|
||||
alternateTitle: getHEICFileNameForJPG(file)));
|
||||
} catch (e) {
|
||||
// Not available locally
|
||||
|
|
|
@ -209,8 +209,12 @@ class PhotoSyncManager {
|
|||
} else {
|
||||
uploadedFile = await _uploader.uploadFile(file);
|
||||
}
|
||||
await _db.update(file.generatedID, uploadedFile.uploadedFileID,
|
||||
uploadedFile.updationTime, file.encryptedPassword, file.encryptedPasswordIV);
|
||||
await _db.update(
|
||||
file.generatedID,
|
||||
uploadedFile.uploadedFileID,
|
||||
uploadedFile.updationTime,
|
||||
file.encryptedPassword,
|
||||
file.encryptedPasswordIV);
|
||||
_prefs.setInt(_syncTimeKey, uploadedFile.updationTime);
|
||||
Bus.instance.fire(PhotoUploadEvent(
|
||||
completed: i + 1, total: photosToBeUploaded.length));
|
||||
|
@ -230,11 +234,13 @@ class PhotoSyncManager {
|
|||
file.deviceFolder,
|
||||
file.creationTime,
|
||||
file.modificationTime,
|
||||
file.encryptedPassword,
|
||||
file.encryptedPasswordIV,
|
||||
alternateTitle: getHEICFileNameForJPG(file));
|
||||
await _db.update(existingPhoto.generatedID, file.uploadedFileID,
|
||||
file.updationTime, file.encryptedPassword, file.encryptedPasswordIV);
|
||||
await _db.update(
|
||||
existingPhoto.generatedID,
|
||||
file.uploadedFileID,
|
||||
file.updationTime,
|
||||
file.encryptedPassword,
|
||||
file.encryptedPasswordIV);
|
||||
} catch (e) {
|
||||
file.localID = null; // File uploaded from a different device
|
||||
await _db.insert(file);
|
||||
|
|
Loading…
Add table
Reference in a new issue