diff --git a/lib/db/folder_db.dart b/lib/db/folder_db.dart index aa5e44a4e..00ed2a32d 100644 --- a/lib/db/folder_db.dart +++ b/lib/db/folder_db.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:io'; import 'package:path/path.dart'; @@ -6,7 +7,8 @@ import 'package:sqflite/sqflite.dart'; import 'package:path_provider/path_provider.dart'; class FolderDB { - static final _databaseName = "ente.db"; + // TODO: Use different tables within the same database + static final _databaseName = "ente.folder.db"; static final _databaseVersion = 1; static final table = 'folders'; @@ -87,7 +89,7 @@ class FolderDB { row[columnName] = folder.name; row[columnOwner] = folder.owner; row[columnDeviceFolder] = folder.deviceFolder; - row[columnSharedWith] = folder.sharedWith.toString(); + row[columnSharedWith] = jsonEncode(folder.sharedWith.toList()); row[columnUpdateTimestamp] = folder.updateTimestamp; return row; } @@ -98,7 +100,9 @@ class FolderDB { row[columnName], row[columnOwner], row[columnDeviceFolder], - Set.from(row[columnSharedWith]), + (jsonDecode(row[columnSharedWith]) as List) + .cast() + .toSet(), row[columnUpdateTimestamp], ); } diff --git a/lib/db/photo_db.dart b/lib/db/photo_db.dart index 74e490a8c..f8d716809 100644 --- a/lib/db/photo_db.dart +++ b/lib/db/photo_db.dart @@ -6,7 +6,8 @@ import 'package:sqflite/sqflite.dart'; import 'package:path_provider/path_provider.dart'; class PhotoDB { - static final _databaseName = "ente.db"; + // TODO: Use different tables within the same database + static final _databaseName = "ente.photos.db"; static final _databaseVersion = 1; static final table = 'photos'; @@ -85,7 +86,7 @@ class PhotoDB { final db = await instance.database; final results = await db.query( table, - where: '$columnIsDeleted = 0', + where: '$columnLocalId IS NOT NULL AND $columnIsDeleted = 0', orderBy: '$columnCreateTimestamp DESC', ); return _convertToPhotos(results);