Rename sync-timestamp to update-timestamp
This commit is contained in:
parent
9e599af31e
commit
995c97add3
4 changed files with 17 additions and 17 deletions
|
@ -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<int> updatePhoto(int generatedId, int uploadedId, String remotePath,
|
||||
int syncTimestamp) async {
|
||||
int updateTimestamp) async {
|
||||
final db = await instance.database;
|
||||
final values = new Map<String, dynamic>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class Photo {
|
|||
int remoteFolderId;
|
||||
String remotePath;
|
||||
int createTimestamp;
|
||||
int syncTimestamp;
|
||||
int updateTimestamp;
|
||||
|
||||
Photo();
|
||||
Photo.fromJson(Map<String, dynamic> json)
|
||||
|
@ -25,7 +25,7 @@ class Photo {
|
|||
title = json["title"],
|
||||
remotePath = json["path"],
|
||||
createTimestamp = json["createTimestamp"],
|
||||
syncTimestamp = json["syncTimestamp"];
|
||||
updateTimestamp = json["updateTimestamp"];
|
||||
|
||||
static Future<Photo> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue