Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Move

Neeraj Gupta3bf715fd462f
diff --git a/mobile/lib/services/files_service.dart b/mobile/lib/services/files_service.dart
index a72db91a9e..36cfe7d50d 100644
--- a/mobile/lib/services/files_service.dart
+++ b/mobile/lib/services/files_service.dart
@@ -5,9 +5,11 @@ import 'package:logging/logging.dart';
import 'package:path/path.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/network/network.dart';
+import "package:photos/db/device_files_db.dart";
import 'package:photos/db/files_db.dart';
import 'package:photos/extensions/list.dart';
import "package:photos/generated/l10n.dart";
+import "package:photos/models/backup_status.dart";
import 'package:photos/models/file/file.dart';
import "package:photos/models/file_load_result.dart";
import "package:photos/models/metadata/file_magic.dart";
@@ -71,6 +73,39 @@ class FilesService {
}
}
+ Future<BackupStatus> getBackupStatus({String? pathID}) async {
+ BackedUpFileIDs ids;
+ final bool hasMigratedSize = await FilesService.instance.hasMigratedSizes();
+ if (pathID == null) {
+ ids = await FilesDB.instance.getBackedUpIDs();
+ } else {
+ ids = await FilesDB.instance.getBackedUpForDeviceCollection(
+ pathID,
+ Configuration.instance.getUserID()!,
+ );
+ }
+ late int size;
+ if (hasMigratedSize) {
+ size = ids.localSize;
+ } else {
+ size = await _getFileSize(ids.uploadedIDs);
+ }
+ return BackupStatus(ids.localIDs, size);
+ }
+
+ Future<int> _getFileSize(List<int> fileIDs) async {
+ try {
+ final response = await _enteDio.post(
+ "/files/size",
+ data: {"fileIDs": fileIDs},
+ );
+ return response.data["size"];
+ } catch (e) {
+ _logger.severe(e);
+ rethrow;
+ }
+ }
+
Future<Map<int, int>> getFilesSizeFromInfo(List<int> uploadedFileID) async {
try {
final response = await _enteDio.post(
diff --git a/mobile/lib/services/sync_service.dart b/mobile/lib/services/sync_service.dart
index f015c9a82c..66291e02d1 100644
--- a/mobile/lib/services/sync_service.dart
+++ b/mobile/lib/services/sync_service.dart
@@ -10,16 +10,12 @@ import 'package:photos/core/constants.dart';
import 'package:photos/core/errors.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/core/network/network.dart';
-import 'package:photos/db/device_files_db.dart';
-import 'package:photos/db/files_db.dart';
import 'package:photos/events/permission_granted_event.dart';
import 'package:photos/events/subscription_purchased_event.dart';
import 'package:photos/events/sync_status_update_event.dart';
import 'package:photos/events/trigger_logout_event.dart';
-import 'package:photos/models/backup_status.dart';
import 'package:photos/models/file/file_type.dart';
import "package:photos/services/filedata/filedata_service.dart";
-import "package:photos/services/files_service.dart";
import 'package:photos/services/local_sync_service.dart';
import 'package:photos/services/notification_service.dart';
import 'package:photos/services/remote_sync_service.dart';
@@ -202,39 +198,6 @@ class SyncService {
);
}
- Future<BackupStatus> getBackupStatus({String? pathID}) async {
- BackedUpFileIDs ids;
- final bool hasMigratedSize = await FilesService.instance.hasMigratedSizes();
- if (pathID == null) {
- ids = await FilesDB.instance.getBackedUpIDs();
- } else {
- ids = await FilesDB.instance.getBackedUpForDeviceCollection(
- pathID,
- Configuration.instance.getUserID()!,
- );
- }
- late int size;
- if (hasMigratedSize) {
- size = ids.localSize;
- } else {
- size = await _getFileSize(ids.uploadedIDs);
- }
- return BackupStatus(ids.localIDs, size);
- }
-
- Future<int> _getFileSize(List<int> fileIDs) async {
- try {
- final response = await _enteDio.post(
- "/files/size",
- data: {"fileIDs": fileIDs},
- );
- return response.data["size"];
- } catch (e) {
- _logger.severe(e);
- rethrow;
- }
- }
-
Future<void> _doSync() async {
await _localSyncService.sync();
if (_localSyncService.hasCompletedFirstImport()) {
diff --git a/mobile/lib/ui/settings/backup/free_space_options.dart b/mobile/lib/ui/settings/backup/free_space_options.dart
index 09879f4ebf..c285bf507e 100644
--- a/mobile/lib/ui/settings/backup/free_space_options.dart
+++ b/mobile/lib/ui/settings/backup/free_space_options.dart
@@ -7,7 +7,7 @@ import "package:photos/models/backup_status.dart";
import "package:photos/models/duplicate_files.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/deduplication_service.dart";
-import "package:photos/services/sync_service.dart";
+import "package:photos/services/files_service.dart";
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
import 'package:photos/ui/components/buttons/icon_button_widget.dart';
@@ -93,7 +93,7 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
onTap: () async {
BackupStatus status;
try {
- status = await SyncService.instance
+ status = await FilesService.instance
.getBackupStatus();
} catch (e) {
await showGenericErrorDialog(
diff --git a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 34c3c04b77..941af3965b 100644
--- a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -26,7 +26,7 @@ import "package:photos/models/metadata/common_keys.dart";
import 'package:photos/models/selected_files.dart';
import 'package:photos/service_locator.dart';
import 'package:photos/services/collections_service.dart';
-import 'package:photos/services/sync_service.dart';
+import "package:photos/services/files_service.dart";
import "package:photos/states/location_screen_state.dart";
import "package:photos/theme/colors.dart";
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
@@ -296,7 +296,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
await dialog.show();
BackupStatus status;
try {
- status = await SyncService.instance
+ status = await FilesService.instance
.getBackupStatus(pathID: widget.deviceCollection!.id);
} catch (e) {
await dialog.hide();