store device collection upload strategy
This commit is contained in:
parent
9e78775167
commit
010982a0c0
|
@ -5,6 +5,7 @@ import 'package:photos/db/files_db.dart';
|
|||
import 'package:photos/models/device_collection.dart';
|
||||
import 'package:photos/models/file.dart';
|
||||
import 'package:photos/models/file_load_result.dart';
|
||||
import 'package:photos/models/upload_strategy.dart';
|
||||
import 'package:photos/services/local/local_sync_util.dart';
|
||||
import 'package:sqflite/sqlite_api.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
@ -313,6 +314,7 @@ extension DeviceFiles on FilesDB {
|
|||
collectionID: row["collection_id"],
|
||||
coverId: row["cover_id"],
|
||||
shouldBackup: (row["should_backup"] ?? _sqlBoolFalse) == _sqlBoolTrue,
|
||||
uploadStrategy: getUploadType(row["upload_strategy"] ?? 0),
|
||||
);
|
||||
if (includeCoverThumbnail) {
|
||||
deviceCollection.thumbnail = coverFiles.firstWhere(
|
||||
|
|
|
@ -317,6 +317,7 @@ class FilesDB {
|
|||
should_backup INTEGER NOT NULL DEFAULT 0,
|
||||
count INTEGER NOT NULL DEFAULT 0,
|
||||
collection_id INTEGER DEFAULT -1,
|
||||
upload_strategy INTEGER DEFAULT 0,
|
||||
cover_id TEXT
|
||||
);
|
||||
''',
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:photos/models/file.dart';
|
||||
import 'package:photos/models/upload_strategy.dart';
|
||||
|
||||
class DeviceCollection {
|
||||
final String id;
|
||||
|
@ -6,6 +7,7 @@ class DeviceCollection {
|
|||
final String coverId;
|
||||
final int count;
|
||||
final bool shouldBackup;
|
||||
UploadStrategy uploadStrategy;
|
||||
int collectionID;
|
||||
File thumbnail;
|
||||
|
||||
|
@ -16,6 +18,7 @@ class DeviceCollection {
|
|||
this.count,
|
||||
this.collectionID,
|
||||
this.thumbnail,
|
||||
this.uploadStrategy = UploadStrategy.ifMissing,
|
||||
this.shouldBackup = false,
|
||||
});
|
||||
}
|
||||
|
|
30
lib/models/upload_strategy.dart
Normal file
30
lib/models/upload_strategy.dart
Normal file
|
@ -0,0 +1,30 @@
|
|||
enum UploadStrategy {
|
||||
// uploader will only try to upload the file in a collection if the file is
|
||||
// not already uploaded
|
||||
ifMissing,
|
||||
// alwaysUpload will always try to upload or add the file to given collection
|
||||
always,
|
||||
other,
|
||||
}
|
||||
|
||||
int getInt(UploadStrategy uploadType) {
|
||||
switch (uploadType) {
|
||||
case UploadStrategy.ifMissing:
|
||||
return 0;
|
||||
case UploadStrategy.always:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
UploadStrategy getUploadType(int uploadType) {
|
||||
switch (uploadType) {
|
||||
case 0:
|
||||
return UploadStrategy.ifMissing;
|
||||
case 1:
|
||||
return UploadStrategy.always;
|
||||
default:
|
||||
return UploadStrategy.other;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue