[mob] Move
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user