Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move upload data models

Neeraj Gupta2ecabc6df8a1
diff --git a/mobile/apps/photos/lib/db/files_db.dart b/mobile/apps/photos/lib/db/files_db.dart
index 3e0d166e8a..0ac4cc5ca6 100644
--- a/mobile/apps/photos/lib/db/files_db.dart
+++ b/mobile/apps/photos/lib/db/files_db.dart
@@ -15,8 +15,8 @@ import 'package:photos/models/file_load_result.dart';
import 'package:photos/models/freeable_space_info.dart';
import 'package:photos/models/location/location.dart';
import "package:photos/models/metadata/common_keys.dart";
+import 'package:photos/module/upload/model/media_upload_data.dart';
import "package:photos/services/filter/db_filters.dart";
-import 'package:photos/utils/file_uploader_util.dart';
import 'package:sqlite_async/sqlite_async.dart';
class FilesDB with SqlDbBase {
diff --git a/mobile/apps/photos/lib/models/file/file.dart b/mobile/apps/photos/lib/models/file/file.dart
index c1ece3d22f..371bbd25a8 100644
--- a/mobile/apps/photos/lib/models/file/file.dart
+++ b/mobile/apps/photos/lib/models/file/file.dart
@@ -11,8 +11,8 @@ import 'package:photos/models/file/file_type.dart';
import 'package:photos/models/location/location.dart';
import "package:photos/models/metadata/file_magic.dart";
import "package:photos/module/download/file_url.dart";
+import 'package:photos/module/upload/model/media_upload_data.dart';
import 'package:photos/utils/exif_util.dart';
-import 'package:photos/utils/file_uploader_util.dart';
import "package:photos/utils/panorama_util.dart";
//Todo: files with no location data have lat and long set to 0.0. This should ideally be null.
diff --git a/mobile/apps/photos/lib/module/upload/model/media_upload_data.dart b/mobile/apps/photos/lib/module/upload/model/media_upload_data.dart
new file mode 100644
index 0000000000..115bebc9fb
--- /dev/null
+++ b/mobile/apps/photos/lib/module/upload/model/media_upload_data.dart
@@ -0,0 +1,48 @@
+import 'dart:io';
+import 'dart:typed_data';
+
+import 'package:exif_reader/exif_reader.dart';
+
+class MediaUploadData {
+ final File? sourceFile;
+ final Uint8List? thumbnail;
+ final bool isDeleted;
+ final FileHashData? hashData;
+ final int? height;
+ final int? width;
+ final String? cameraMake;
+ final String? cameraModel;
+
+ // For android motion photos, the startIndex is the index of the first frame
+ // For iOS, this value will be always null.
+ final int? motionPhotoStartIndex;
+
+ final Map<String, IfdTag>? exifData;
+
+ bool? isPanorama;
+
+ MediaUploadData(
+ this.sourceFile,
+ this.thumbnail,
+ this.isDeleted,
+ this.hashData, {
+ this.height,
+ this.width,
+ this.cameraMake,
+ this.cameraModel,
+ this.motionPhotoStartIndex,
+ this.isPanorama,
+ this.exifData,
+ });
+}
+
+class FileHashData {
+ // For livePhotos, the fileHash value will be imageHash:videoHash
+ final String? fileHash;
+
+ // zipHash is used to take care of existing live photo uploads from older
+ // mobile clients
+ String? zipHash;
+
+ FileHashData(this.fileHash, {this.zipHash});
+}
diff --git a/mobile/apps/photos/lib/services/local_file_update_service.dart b/mobile/apps/photos/lib/services/local_file_update_service.dart
index 6dafb9387c..2a5752a2d5 100644
--- a/mobile/apps/photos/lib/services/local_file_update_service.dart
+++ b/mobile/apps/photos/lib/services/local_file_update_service.dart
@@ -11,6 +11,7 @@ import 'package:photos/db/file_updation_db.dart';
import 'package:photos/db/files_db.dart';
import 'package:photos/models/file/file.dart';
import 'package:photos/models/file/file_type.dart';
+import 'package:photos/module/upload/model/media_upload_data.dart';
import 'package:photos/utils/file_uploader_util.dart';
import 'package:photos/utils/file_util.dart';
import 'package:shared_preferences/shared_preferences.dart';
diff --git a/mobile/apps/photos/lib/services/sync/offline_import_metadata_service.dart b/mobile/apps/photos/lib/services/sync/offline_import_metadata_service.dart
index 1e52bd502a..264b26c33b 100644
--- a/mobile/apps/photos/lib/services/sync/offline_import_metadata_service.dart
+++ b/mobile/apps/photos/lib/services/sync/offline_import_metadata_service.dart
@@ -10,9 +10,9 @@ import "package:photos/events/local_photos_updated_event.dart";
import "package:photos/models/file/extensions/file_props.dart";
import "package:photos/models/file/file.dart";
import "package:photos/models/location/location.dart";
+import "package:photos/module/upload/model/media_upload_data.dart";
import "package:photos/service_locator.dart";
import "package:photos/utils/exif_util.dart";
-import "package:photos/utils/file_uploader_util.dart";
import "package:photos/utils/file_util.dart";
class OfflineImportMetadataService {
diff --git a/mobile/apps/photos/lib/utils/file_uploader.dart b/mobile/apps/photos/lib/utils/file_uploader.dart
index 79424b8354..f039d68580 100644
--- a/mobile/apps/photos/lib/utils/file_uploader.dart
+++ b/mobile/apps/photos/lib/utils/file_uploader.dart
@@ -30,6 +30,7 @@ import 'package:photos/models/file/file.dart';
import 'package:photos/models/file/file_type.dart';
import "package:photos/models/metadata/file_magic.dart";
import "package:photos/models/user_details.dart";
+import 'package:photos/module/upload/model/media_upload_data.dart';
import 'package:photos/module/upload/model/upload_url.dart';
import "package:photos/module/upload/service/multipart.dart";
import "package:photos/service_locator.dart";
diff --git a/mobile/apps/photos/lib/utils/file_uploader_util.dart b/mobile/apps/photos/lib/utils/file_uploader_util.dart
index 1ed0bb6f6d..8be330a922 100644
--- a/mobile/apps/photos/lib/utils/file_uploader_util.dart
+++ b/mobile/apps/photos/lib/utils/file_uploader_util.dart
@@ -25,6 +25,7 @@ import 'package:photos/models/file/file.dart';
import 'package:photos/models/file/file_type.dart';
import "package:photos/models/location/location.dart";
import "package:photos/models/metadata/file_magic.dart";
+import 'package:photos/module/upload/model/media_upload_data.dart';
import "package:photos/services/sync/local_sync_service.dart";
import "package:photos/src/rust/api/motion_photo_api.dart";
import "package:photos/utils/apple_photos_errors.dart";
@@ -36,50 +37,6 @@ import 'package:video_thumbnail/video_thumbnail.dart';
final _logger = Logger("FileUtil");
const kMaximumThumbnailCompressionAttempts = 2;
-class MediaUploadData {
- final File? sourceFile;
- final Uint8List? thumbnail;
- final bool isDeleted;
- final FileHashData? hashData;
- final int? height;
- final int? width;
- final String? cameraMake;
- final String? cameraModel;
-
- // For android motion photos, the startIndex is the index of the first frame
- // For iOS, this value will be always null.
- final int? motionPhotoStartIndex;
-
- final Map<String, IfdTag>? exifData;
-
- bool? isPanorama;
-
- MediaUploadData(
- this.sourceFile,
- this.thumbnail,
- this.isDeleted,
- this.hashData, {
- this.height,
- this.width,
- this.cameraMake,
- this.cameraModel,
- this.motionPhotoStartIndex,
- this.isPanorama,
- this.exifData,
- });
-}
-
-class FileHashData {
- // For livePhotos, the fileHash value will be imageHash:videoHash
- final String? fileHash;
-
- // zipHash is used to take care of existing live photo uploads from older
- // mobile clients
- String? zipHash;
-
- FileHashData(this.fileHash, {this.zipHash});
-}
-
String? _extractPrintableExifValue(IfdTag? tag) {
final printableValue = tag?.printable;
final printable = printableValue?.trim();