Sfoglia il codice sorgente

Handle lack of permissions gracefully

Vishnu Mohandas 4 anni fa
parent
commit
96456bf01f
1 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 6 2
      lib/services/sync_service.dart

+ 6 - 2
lib/services/sync_service.dart

@@ -118,12 +118,15 @@ class SyncService {
   }
 
   Future<void> _doSync() async {
+    final existingLocalFileIDs = await _db.getExistingLocalFileIDs();
+    final syncStartTime = DateTime.now().microsecondsSinceEpoch;
     final result = await PhotoManager.requestPermission();
     if (!result) {
       _logger.severe("Did not get permission");
+      await _prefs.setInt(_dbUpdationTimeKey, syncStartTime);
+      await FileRepository.instance.reloadFiles();
+      return await syncWithRemote();
     }
-    final existingLocalFileIDs = await _db.getExistingLocalFileIDs();
-    final syncStartTime = DateTime.now().microsecondsSinceEpoch;
     final lastDBUpdationTime = _prefs.getInt(_dbUpdationTimeKey);
     if (lastDBUpdationTime != null && lastDBUpdationTime != 0) {
       await _loadAndStorePhotos(
@@ -141,6 +144,7 @@ class SyncService {
       }
       await _loadAndStorePhotos(startTime, syncStartTime, existingLocalFileIDs);
     }
+    await FileRepository.instance.reloadFiles();
     await syncWithRemote();
   }