diff --git a/lib/db/photo_db.dart b/lib/db/photo_db.dart index 8c01573fe..04e75c6e9 100644 --- a/lib/db/photo_db.dart +++ b/lib/db/photo_db.dart @@ -19,6 +19,7 @@ class PhotoDB { static final columnDeviceFolder = 'device_folder'; static final columnRemoteFolderId = 'remote_folder_id'; static final columnRemotePath = 'remote_path'; + static final columnThumbnailPath = 'thumbnail_path'; static final columnIsDeleted = 'is_deleted'; static final columnCreateTimestamp = 'create_timestamp'; static final columnUpdateTimestamp = 'update_timestamp'; @@ -55,6 +56,7 @@ class PhotoDB { $columnDeviceFolder TEXT NOT NULL, $columnRemoteFolderId INTEGER DEFAULT -1, $columnRemotePath TEXT, + $columnThumbnailPath TEXT, $columnIsDeleted INTEGER DEFAULT 0, $columnCreateTimestamp TEXT NOT NULL, $columnUpdateTimestamp TEXT @@ -138,12 +140,14 @@ class PhotoDB { } } - Future updatePhoto(int generatedId, int uploadedId, String remotePath, - int updateTimestamp) async { + Future updatePhoto( + int generatedId, int uploadedId, String remotePath, int updateTimestamp, + [String thumbnailPath]) async { final db = await instance.database; final values = new Map(); values[columnUploadedFileId] = uploadedId; values[columnRemotePath] = remotePath; + values[columnThumbnailPath] = thumbnailPath; values[columnUpdateTimestamp] = updateTimestamp; return await db.update( table, @@ -277,6 +281,7 @@ class PhotoDB { row[columnDeviceFolder] = photo.deviceFolder; row[columnRemoteFolderId] = photo.remoteFolderId; row[columnRemotePath] = photo.remotePath; + row[columnThumbnailPath] = photo.thumbnailPath; row[columnCreateTimestamp] = photo.createTimestamp; row[columnUpdateTimestamp] = photo.updateTimestamp; return row; @@ -291,6 +296,7 @@ class PhotoDB { photo.deviceFolder = row[columnDeviceFolder]; photo.remoteFolderId = row[columnRemoteFolderId]; photo.remotePath = row[columnRemotePath]; + photo.thumbnailPath = row[columnThumbnailPath]; photo.createTimestamp = int.parse(row[columnCreateTimestamp]); photo.updateTimestamp = row[columnUpdateTimestamp] == null ? -1 diff --git a/lib/models/photo.dart b/lib/models/photo.dart index 311088a70..eeaa1a9fb 100644 --- a/lib/models/photo.dart +++ b/lib/models/photo.dart @@ -14,6 +14,7 @@ class Photo { String deviceFolder; int remoteFolderId; String remotePath; + String thumbnailPath; int createTimestamp; int updateTimestamp; @@ -24,6 +25,7 @@ class Photo { deviceFolder = json["deviceFolder"], title = json["title"], remotePath = json["path"], + thumbnailPath = json["previewURL"], createTimestamp = json["createTimestamp"], updateTimestamp = json["updateTimestamp"]; diff --git a/lib/photo_sync_manager.dart b/lib/photo_sync_manager.dart index 0dc180c90..d0f3f690f 100644 --- a/lib/photo_sync_manager.dart +++ b/lib/photo_sync_manager.dart @@ -149,7 +149,7 @@ 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.updateTimestamp); + photo.remotePath, photo.updateTimestamp, photo.thumbnailPath); } catch (e) { await _db.insertPhoto(photo); }