Browse Source

Merge pull request #553 from ente-io/fix_sql

Vishnu Mohandas 2 years ago
parent
commit
ab9b5dc3c4
3 changed files with 5 additions and 4 deletions
  1. 1 1
      ios/Podfile.lock
  2. 2 1
      lib/db/device_files_db.dart
  3. 2 2
      lib/services/local/local_sync_util.dart

+ 1 - 1
ios/Podfile.lock

@@ -316,7 +316,7 @@ SPEC CHECKSUMS:
   FirebaseInstallations: 0a115432c4e223c5ab20b0dbbe4cbefa793a0e8e
   FirebaseMessaging: 732623518591384f61c287e3d8f65294beb7ffb3
   fk_user_agent: 1f47ec39291e8372b1d692b50084b0d54103c545
-  Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
+  Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
   flutter_email_sender: 02d7443217d8c41483223627972bfdc09f74276b
   flutter_image_compress: 5a5e9aee05b6553048b8df1c3bc456d0afaac433
   flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721

+ 2 - 1
lib/db/device_files_db.dart

@@ -387,8 +387,9 @@ extension DeviceFiles on FilesDB {
     final db = await database;
     final fileRows = await db.rawQuery(
       '''SELECT * FROM FILES  f JOIN device_files df on f.local_id = df.id 
-      and df.path_id=$pathID order by f.modification_time DESC limit 1;
+      and df.path_id= ? order by f.modification_time DESC limit 1;
           ''',
+      [pathID],
     );
     final files = convertToFiles(fileRows);
     if (files.isNotEmpty) {

+ 2 - 2
lib/services/local/local_sync_util.dart

@@ -70,12 +70,12 @@ Future<List<Tuple2<AssetPathEntity, String>>>
         const OrderOption(type: OrderOptionType.createDate, asc: false),
   );
   for (AssetPathEntity pathEntity in pathEntities) {
-    //todo: test and handle empty album case
     final latestEntity = await pathEntity.getAssetListPaged(
       page: 0,
       size: 1,
     );
-    final String localCoverID = latestEntity.first.id;
+    final String localCoverID =
+        latestEntity.isEmpty ? '' : latestEntity.first.id;
     result.add(Tuple2(pathEntity, localCoverID));
   }
   return result;