From cecdea3f93933346bcf20f1108a89fdab475fc52 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 20 Jun 2025 13:21:14 +0530 Subject: [PATCH] Rename --- mobile/lib/models/file/file.dart | 43 +++++++++---------- mobile/lib/models/selected_files.dart | 4 +- .../services/collections_service_mapper.dart | 10 ++--- .../services/remote/assets/remote_cache.dart | 6 +-- .../lib/ui/viewer/file/thumbnail_widget.dart | 2 +- mobile/lib/utils/file_download_util.dart | 2 +- mobile/lib/utils/thumbnail_util.dart | 2 +- 7 files changed, 34 insertions(+), 35 deletions(-) diff --git a/mobile/lib/models/file/file.dart b/mobile/lib/models/file/file.dart index ce22750987..b803891acd 100644 --- a/mobile/lib/models/file/file.dart +++ b/mobile/lib/models/file/file.dart @@ -19,7 +19,7 @@ import 'package:photos/utils/standalone/date_time.dart'; //Todo: files with no location data have lat and long set to 0.0. This should ideally be null. class EnteFile { - AssetEntity? asset; + AssetEntity? lAsset; RemoteAsset? remoteAsset; CollectionFileEntry? fileEntry; int? generatedID; @@ -78,7 +78,7 @@ class EnteFile { static Future fromAsset(String pathName, AssetEntity asset) async { final EnteFile file = EnteFile(); - file.asset = asset; + file.lAsset = asset; file.localID = asset.id; file.title = asset.title; file.deviceFolder = pathName; @@ -94,7 +94,7 @@ class EnteFile { static EnteFile fromAssetSync(AssetEntity asset) { final EnteFile file = EnteFile(); - file.asset = asset; + file.lAsset = asset; file.localID = asset.id; file.title = asset.title; file.deviceFolder = asset.relativePath; @@ -118,35 +118,34 @@ class EnteFile { } static EnteFile fromRemoteAsset( - RemoteAsset remoteAsset, + RemoteAsset rAsset, CollectionFileEntry collection, { - AssetEntity? asset, + AssetEntity? lAsset, }) { final EnteFile file = EnteFile(); - file.remoteAsset = remoteAsset; + file.remoteAsset = rAsset; file.fileEntry = collection; - file.asset = asset; + file.lAsset = lAsset; - file.uploadedFileID = remoteAsset.id; - file.ownerID = remoteAsset.ownerID; - file.title = remoteAsset.title; - file.deviceFolder = remoteAsset.deviceFolder; - file.location = remoteAsset.location; - file.fileType = remoteAsset.fileType; - file.creationTime = remoteAsset.creationTime; - file.modificationTime = remoteAsset.modificationTime; - file.fileSubType = remoteAsset.subType; + file.uploadedFileID = rAsset.id; + file.ownerID = rAsset.ownerID; + file.title = rAsset.title; + file.deviceFolder = rAsset.deviceFolder; + file.location = rAsset.location; + file.fileType = rAsset.fileType; + file.creationTime = rAsset.creationTime; + file.modificationTime = rAsset.modificationTime; + file.fileSubType = rAsset.subType; file.metadataVersion = kCurrentMetadataVersion; - file.duration = remoteAsset.durationInSec; - file.fileSize = remoteAsset.fileSize; + file.duration = rAsset.durationInSec; + file.fileSize = rAsset.fileSize; file.collectionID = collection.collectionID; file.encryptedKey = CryptoUtil.bin2base64(collection.encFileKey); file.keyDecryptionNonce = CryptoUtil.bin2base64(collection.encFileKeyNonce); file.pubMagicMetadata = - PubMagicMetadata.fromMap(remoteAsset.publicMetadata?.data); - file.magicMetadata = - MagicMetadata.fromMap(remoteAsset.privateMetadata?.data); + PubMagicMetadata.fromMap(rAsset.publicMetadata?.data); + file.magicMetadata = MagicMetadata.fromMap(rAsset.privateMetadata?.data); return file; } @@ -423,7 +422,7 @@ class EnteFile { PubMagicMetadata? pubMagicMetadata, }) { return EnteFile() - ..asset = asset + ..lAsset = lAsset ..remoteAsset = remoteAsset ..fileEntry = fileEntry ..generatedID = generatedID ?? this.generatedID diff --git a/mobile/lib/models/selected_files.dart b/mobile/lib/models/selected_files.dart index b51ad9709d..23bafa2cf4 100644 --- a/mobile/lib/models/selected_files.dart +++ b/mobile/lib/models/selected_files.dart @@ -75,8 +75,8 @@ class SelectedFiles extends ChangeNotifier { } } else if (first.uploadedFileID != null && second.uploadedFileID != null) { return first.uploadedFileID == second.uploadedFileID; - } else if (first.asset != null && second.asset != null) { - return first.asset!.id == second.asset!.id; + } else if (first.lAsset != null && second.lAsset != null) { + return first.lAsset!.id == second.lAsset!.id; } return false; } diff --git a/mobile/lib/services/collections_service_mapper.dart b/mobile/lib/services/collections_service_mapper.dart index 4db1284f50..71f0759cbe 100644 --- a/mobile/lib/services/collections_service_mapper.dart +++ b/mobile/lib/services/collections_service_mapper.dart @@ -7,7 +7,7 @@ import "package:photos/utils/file_key.dart"; extension CollectionsServiceMapper on CollectionsService { EnteFile moveOrAddEntry(EnteFile file, int destCollectionID) { - if (file.remoteAsset == null || file.fileEntry == null) { + if (file.rAsset == null || file.fileEntry == null) { throw ArgumentError( "File must have remoteAsset and fileEntry to be mapped.", ); @@ -15,7 +15,7 @@ extension CollectionsServiceMapper on CollectionsService { final fileKey = getFileKey(file); final encResult = CryptoUtil.encryptSync(fileKey, getCollectionKey(destCollectionID)); - final remoteAsset = file.remoteAsset!; + final remoteAsset = file.rAsset!; final oldCF = file.fileEntry!; final newCF = CollectionFileEntry( collectionID: destCollectionID, @@ -28,15 +28,15 @@ extension CollectionsServiceMapper on CollectionsService { return EnteFile.fromRemoteAsset( remoteAsset, newCF, - asset: file.asset, + lAsset: file.lAsset, ); } DiffFileItem buildDiffItem(EnteFile file) { - if (file.remoteAsset == null || file.fileEntry == null) { + if (file.rAsset == null || file.fileEntry == null) { throw ArgumentError("must have remoteAsset and fileEntry"); } - final remoteAsset = file.remoteAsset!; + final remoteAsset = file.rAsset!; final cf = file.fileEntry!; if (remoteAsset.id != cf.fileID) { throw ArgumentError("File ID in remote asset does not match file entry."); diff --git a/mobile/lib/services/remote/assets/remote_cache.dart b/mobile/lib/services/remote/assets/remote_cache.dart index 021604b361..190b05cc7a 100644 --- a/mobile/lib/services/remote/assets/remote_cache.dart +++ b/mobile/lib/services/remote/assets/remote_cache.dart @@ -72,11 +72,11 @@ class RemoteCache { } final _ = isLoaded ?? await _load(); - final asset = remoteAssets[cf.fileID]; - if (asset == null) { + final rAsset = remoteAssets[cf.fileID]; + if (rAsset == null) { return null; } - return EnteFile.fromRemoteAsset(asset, cf); + return EnteFile.fromRemoteAsset(rAsset, cf); } Future getAnyCollectionFile(int fileID) async { diff --git a/mobile/lib/ui/viewer/file/thumbnail_widget.dart b/mobile/lib/ui/viewer/file/thumbnail_widget.dart index a3844f43e6..404bb1e546 100644 --- a/mobile/lib/ui/viewer/file/thumbnail_widget.dart +++ b/mobile/lib/ui/viewer/file/thumbnail_widget.dart @@ -144,7 +144,7 @@ class _ThumbnailWidgetState extends State { _hasLoadedThumbnail = true; } else { localImageProviderKey = LocalThumbnailProviderKey( - asset: widget.file.asset!, + asset: widget.file.lAsset!, height: widget.thumbnailSize, width: widget.thumbnailSize, ); diff --git a/mobile/lib/utils/file_download_util.dart b/mobile/lib/utils/file_download_util.dart index 4e23b0ccb4..784eb15f7b 100644 --- a/mobile/lib/utils/file_download_util.dart +++ b/mobile/lib/utils/file_download_util.dart @@ -176,7 +176,7 @@ Future downloadAndDecrypt( await CryptoUtil.decryptFile( encryptedFilePath, decryptedFilePath, - file.remoteAsset!.fileHeader, + file.rAsset!.fileHeader, getFileKey(file), ); fakeProgress?.stop(); diff --git a/mobile/lib/utils/thumbnail_util.dart b/mobile/lib/utils/thumbnail_util.dart index 03cd89de96..070d44e678 100644 --- a/mobile/lib/utils/thumbnail_util.dart +++ b/mobile/lib/utils/thumbnail_util.dart @@ -199,7 +199,7 @@ Future _downloadAndDecryptThumbnail(FileDownloadItem item) async { data = await CryptoUtil.decryptChaCha( encryptedThumbnail, thumbnailDecryptionKey, - file.remoteAsset!.thumbHeader, + file.rAsset!.thumbHeader, ); } catch (e, s) { _logger.severe("Failed to decrypt thumbnail ${item.file.toString()}", e, s);