diff --git a/lib/db/photo_db.dart b/lib/db/photo_db.dart index d3ee9571c..8c01573fe 100644 --- a/lib/db/photo_db.dart +++ b/lib/db/photo_db.dart @@ -21,7 +21,7 @@ class PhotoDB { static final columnRemotePath = 'remote_path'; static final columnIsDeleted = 'is_deleted'; static final columnCreateTimestamp = 'create_timestamp'; - static final columnSyncTimestamp = 'sync_timestamp'; + static final columnUpdateTimestamp = 'update_timestamp'; // make this a singleton class PhotoDB._privateConstructor(); @@ -57,7 +57,7 @@ class PhotoDB { $columnRemotePath TEXT, $columnIsDeleted INTEGER DEFAULT 0, $columnCreateTimestamp TEXT NOT NULL, - $columnSyncTimestamp TEXT + $columnUpdateTimestamp TEXT ) '''); } @@ -139,12 +139,12 @@ class PhotoDB { } Future updatePhoto(int generatedId, int uploadedId, String remotePath, - int syncTimestamp) async { + int updateTimestamp) async { final db = await instance.database; final values = new Map(); values[columnUploadedFileId] = uploadedId; values[columnRemotePath] = remotePath; - values[columnSyncTimestamp] = syncTimestamp; + values[columnUpdateTimestamp] = updateTimestamp; return await db.update( table, values, @@ -278,7 +278,7 @@ class PhotoDB { row[columnRemoteFolderId] = photo.remoteFolderId; row[columnRemotePath] = photo.remotePath; row[columnCreateTimestamp] = photo.createTimestamp; - row[columnSyncTimestamp] = photo.syncTimestamp; + row[columnUpdateTimestamp] = photo.updateTimestamp; return row; } @@ -292,9 +292,9 @@ class PhotoDB { photo.remoteFolderId = row[columnRemoteFolderId]; photo.remotePath = row[columnRemotePath]; photo.createTimestamp = int.parse(row[columnCreateTimestamp]); - photo.syncTimestamp = row[columnSyncTimestamp] == null + photo.updateTimestamp = row[columnUpdateTimestamp] == null ? -1 - : int.parse(row[columnSyncTimestamp]); + : int.parse(row[columnUpdateTimestamp]); return photo; } } diff --git a/lib/folder_service.dart b/lib/folder_service.dart index cb32757cb..70d953489 100644 --- a/lib/folder_service.dart +++ b/lib/folder_service.dart @@ -47,7 +47,7 @@ class FolderSharingService { try { Photo photo = await PhotoDB.instance.getLatestPhotoInRemoteFolder(folder.id); - lastSyncTimestamp = photo.syncTimestamp; + lastSyncTimestamp = photo.updateTimestamp; } catch (e) { // Folder has never been synced } diff --git a/lib/models/photo.dart b/lib/models/photo.dart index 849c17c8f..311088a70 100644 --- a/lib/models/photo.dart +++ b/lib/models/photo.dart @@ -15,7 +15,7 @@ class Photo { int remoteFolderId; String remotePath; int createTimestamp; - int syncTimestamp; + int updateTimestamp; Photo(); Photo.fromJson(Map json) @@ -25,7 +25,7 @@ class Photo { title = json["title"], remotePath = json["path"], createTimestamp = json["createTimestamp"], - syncTimestamp = json["syncTimestamp"]; + updateTimestamp = json["updateTimestamp"]; static Future fromAsset( AssetPathEntity pathEntity, AssetEntity asset) async { @@ -75,7 +75,7 @@ class Photo { @override String toString() { - return 'Photo(generatedId: $generatedId, uploadedFileId: $uploadedFileId, localId: $localId, title: $title, deviceFolder: $deviceFolder, remotePath: $remotePath, createTimestamp: $createTimestamp, syncTimestamp: $syncTimestamp)'; + return 'Photo(generatedId: $generatedId, uploadedFileId: $uploadedFileId, localId: $localId, title: $title, deviceFolder: $deviceFolder, remotePath: $remotePath, createTimestamp: $createTimestamp, updateTimestamp: $updateTimestamp)'; } @override @@ -90,7 +90,7 @@ class Photo { o.deviceFolder == deviceFolder && o.remotePath == remotePath && o.createTimestamp == createTimestamp && - o.syncTimestamp == syncTimestamp; + o.updateTimestamp == updateTimestamp; } @override @@ -102,6 +102,6 @@ class Photo { deviceFolder.hashCode ^ remotePath.hashCode ^ createTimestamp.hashCode ^ - syncTimestamp.hashCode; + updateTimestamp.hashCode; } } diff --git a/lib/photo_sync_manager.dart b/lib/photo_sync_manager.dart index 7703e5038..0dc180c90 100644 --- a/lib/photo_sync_manager.dart +++ b/lib/photo_sync_manager.dart @@ -135,8 +135,8 @@ class PhotoSyncManager { return; } await _db.updatePhoto(photo.generatedId, uploadedPhoto.uploadedFileId, - uploadedPhoto.remotePath, uploadedPhoto.syncTimestamp); - prefs.setInt(_lastSyncTimestampKey, uploadedPhoto.syncTimestamp); + uploadedPhoto.remotePath, uploadedPhoto.updateTimestamp); + prefs.setInt(_lastSyncTimestampKey, uploadedPhoto.updateTimestamp); } catch (e) { _logger.severe(e); } @@ -149,11 +149,11 @@ class PhotoSyncManager { var existingPhoto = await _db.getMatchingPhoto(photo.localId, photo.title, photo.deviceFolder, photo.createTimestamp); await _db.updatePhoto(existingPhoto.generatedId, photo.uploadedFileId, - photo.remotePath, photo.syncTimestamp); + photo.remotePath, photo.updateTimestamp); } catch (e) { await _db.insertPhoto(photo); } - await prefs.setInt(_lastSyncTimestampKey, photo.syncTimestamp); + await prefs.setInt(_lastSyncTimestampKey, photo.updateTimestamp); } }