Rename
This commit is contained in:
@@ -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<EnteFile> 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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -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<EnteFile?> getAnyCollectionFile(int fileID) async {
|
||||
|
||||
@@ -144,7 +144,7 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
|
||||
_hasLoadedThumbnail = true;
|
||||
} else {
|
||||
localImageProviderKey = LocalThumbnailProviderKey(
|
||||
asset: widget.file.asset!,
|
||||
asset: widget.file.lAsset!,
|
||||
height: widget.thumbnailSize,
|
||||
width: widget.thumbnailSize,
|
||||
);
|
||||
|
||||
@@ -176,7 +176,7 @@ Future<File?> downloadAndDecrypt(
|
||||
await CryptoUtil.decryptFile(
|
||||
encryptedFilePath,
|
||||
decryptedFilePath,
|
||||
file.remoteAsset!.fileHeader,
|
||||
file.rAsset!.fileHeader,
|
||||
getFileKey(file),
|
||||
);
|
||||
fakeProgress?.stop();
|
||||
|
||||
@@ -199,7 +199,7 @@ Future<void> _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);
|
||||
|
||||
Reference in New Issue
Block a user