π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
cleanup
AmanRajSinghMouryab6401c408141
diff --git a/mobile/apps/locker/lib/services/db/locker_db.dart b/mobile/apps/locker/lib/services/db/locker_db.dartindex f4c7dd0487..70cb9af8ef 100644--- a/mobile/apps/locker/lib/services/db/locker_db.dart+++ b/mobile/apps/locker/lib/services/db/locker_db.dart@@ -580,36 +580,6 @@ class LockerDB extends EnteBaseDatabase {await batch.commit();}- Future<List<EnteFile>> getOfflineMarkedFiles() async {- final markedIds = _offlineMarkedFileIDsCache.toList(growable: false);- if (markedIds.isEmpty) {- return [];- }-- final placeholders = List.filled(markedIds.length, '?').join(',');- final rows = await _db.rawQuery(- '''- SELECT f.*- FROM $_filesTable f- WHERE f.uploaded_file_id IN ($placeholders)- AND EXISTS (- SELECT 1- FROM $_collectionFilesTable cf- INNER JOIN $_collectionsTable c- ON c.id = cf.collection_id- WHERE cf.uploaded_file_id = f.uploaded_file_id- AND c.is_deleted = 0- )- ''',- markedIds,- );- final files = <EnteFile>[];- for (final row in rows) {- files.add(await _mapFromRow(row));- }- return files;- }-bool isFileMarkedOfflineById(int? uploadedFileID) {return uploadedFileID != null &&_offlineMarkedFileIDsCache.contains(uploadedFileID);diff --git a/mobile/apps/locker/lib/services/files/offline/offline_files_service.dart b/mobile/apps/locker/lib/services/files/offline/offline_files_service.dartindex 2b27fcd74c..8134b09089 100644--- a/mobile/apps/locker/lib/services/files/offline/offline_files_service.dart+++ b/mobile/apps/locker/lib/services/files/offline/offline_files_service.dart@@ -91,20 +91,6 @@ class OfflineFilesService {return sharedCount;}- bool hasEligibleFiles(Iterable<EnteFile> files) {- return getEligibleFiles(files).isNotEmpty;- }-- /// The bottom sheet only shows "Remove offline" when every actionable- /// file in the selection is already marked offline on this device.- bool shouldRemoveOfflineForSelection(Iterable<EnteFile> files) {- final eligibleFiles = getEligibleFiles(files);- if (eligibleFiles.isEmpty) {- return false;- }- return eligibleFiles.every(LockerDB.instance.isFileMarkedOffline);- }-/// Downloads the encrypted blob and marks the file offline on success.Future<bool> markFilesOffline(BuildContext context,@@ -302,17 +288,6 @@ class OfflineFilesService {return true;}- Future<void> _setOfflineMarkForFile(- EnteFile file,- bool isMarkedOffline,- ) async {- final fileID = file.uploadedFileID!;- await LockerDB.instance.setFilesMarkedOffline(- [fileID],- isMarkedOffline,- );- }-/// Service-level unmark path used by non-UI flows like trash/delete.Future<void> unmarkFilesOfflineById(Iterable<int> fileIDs, {@@ -361,12 +336,10 @@ class OfflineFilesService {ProgressCallback? progressCallback,}) async {final fileID = file.uploadedFileID!;- if (await getCurrentOfflineEncryptedCopy(file) == null) {- await ensureEncryptedOfflineCopy(- file,- progressCallback: progressCallback,- );- }+ await ensureEncryptedOfflineCopy(+ file,+ progressCallback: progressCallback,+ );if (!await LockerDB.instance.hasActiveFile(fileID)) {_logger.warning(@@ -379,7 +352,7 @@ class OfflineFilesService {return false;}- await _setOfflineMarkForFile(file, true);+ await LockerDB.instance.setFilesMarkedOffline([fileID], true);return true;}diff --git a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dartindex cdf476e6a3..23b50ba628 100644--- a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart+++ b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart@@ -14,6 +14,7 @@ import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";import "package:locker/services/collections/models/collection_view_type.dart";import "package:locker/services/configuration.dart";+import "package:locker/services/db/locker_db.dart";import "package:locker/services/favorites_service.dart";import "package:locker/services/files/offline/offline_files_service.dart";import "package:locker/services/files/sync/models/file.dart";@@ -31,7 +32,7 @@ class FileSelectionOverlayBar extends StatefulWidget {final List<EnteFile> files;final CollectionViewType? collectionViewType;final ScrollController? scrollController;- final bool isTrashMode;+ final bool isTrashMode;const FileSelectionOverlayBar({required this.selectedFiles,@@ -468,12 +469,10 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {final viewType = widget.collectionViewType;final colorScheme = getEnteColorScheme(context);final actions = <Widget>[];- final canToggleOffline =- OfflineFilesService.instance.hasEligibleFiles(files);+ final eligibleFiles = OfflineFilesService.instance.getEligibleFiles(files);+ final canToggleOffline = eligibleFiles.isNotEmpty;final shouldRemoveOffline = canToggleOffline &&- OfflineFilesService.instance.shouldRemoveOfflineForSelection(- files,- );+ eligibleFiles.every(LockerDB.instance.isFileMarkedOffline);final showEdit = viewType?.showEditOption ?? true;final showShare = viewType?.showShareOption ?? true;diff --git a/mobile/apps/locker/lib/utils/file_util.dart b/mobile/apps/locker/lib/utils/file_util.dartindex 6c6a5ac46b..dc4a33c925 100644--- a/mobile/apps/locker/lib/utils/file_util.dart+++ b/mobile/apps/locker/lib/utils/file_util.dart@@ -37,14 +37,14 @@ class FileUtil {if (file.localPath != null) {final localFile = File(file.localPath!);if (await localFile.exists()) {- await _launchFile(context, localFile, file.displayName);+ await _launchFile(context, localFile);return;}}final cachedDecryptedFile = File(getCachedDecryptedFilePath(file));if (await cachedDecryptedFile.exists()) {- await _launchFile(context, cachedDecryptedFile, file.displayName);+ await _launchFile(context, cachedDecryptedFile);return;}@@ -57,7 +57,6 @@ class FileUtil {try {await dialog.show();final fileKey = await CollectionService.instance.getFileKey(file);- File? decryptedFile;void progressCallback(int downloaded, int total) {if (total > 0 && downloaded >= 0) {final percentage = ((downloaded / total) * 100).clamp(0, 100).round();@@ -69,7 +68,7 @@ class FileUtil {}}- decryptedFile = await file_downloader.openFile(+ final decryptedFile = await file_downloader.openFile(file,fileKey,progressCallback: progressCallback,@@ -78,7 +77,7 @@ class FileUtil {await dialog.hide();if (decryptedFile != null) {- await _launchFile(context, decryptedFile, file.displayName);+ await _launchFile(context, decryptedFile);} else {await showAlertBottomSheet(context,@@ -400,7 +399,6 @@ class FileUtil {static Future<void> _launchFile(BuildContext context,File file,- String fileName,) async {try {final result = await OpenFile.open(file.path);