mirror of
https://github.com/ente-io/ente.git
synced 2025-08-14 02:07:33 +00:00
[mob][multipart] Minor refactor
This commit is contained in:
@@ -487,34 +487,17 @@ class FileUploader {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Uint8List? key;
|
Uint8List? key;
|
||||||
EncryptionResult? multiPartFileEncResult;
|
EncryptionResult? multiPartFileEncResult = multipartEntryExists
|
||||||
|
? await _multiPartUploader.getEncryptionResult(
|
||||||
|
lockKey,
|
||||||
|
mediaUploadData.hashData!.fileHash!,
|
||||||
|
collectionID,
|
||||||
|
)
|
||||||
|
: null;
|
||||||
if (isUpdatedFile) {
|
if (isUpdatedFile) {
|
||||||
key = getFileKey(file);
|
key = getFileKey(file);
|
||||||
multiPartFileEncResult = multipartEntryExists
|
|
||||||
? await _multiPartUploader.getEncryptionResult(
|
|
||||||
lockKey,
|
|
||||||
mediaUploadData.hashData!.fileHash!,
|
|
||||||
collectionID,
|
|
||||||
)
|
|
||||||
: null;
|
|
||||||
if (multiPartFileEncResult?.key != null &&
|
|
||||||
!listEquals(key, multiPartFileEncResult!.key)) {
|
|
||||||
_logger
|
|
||||||
.severe("Key mismatch for existing multipart entry, reuploading");
|
|
||||||
await _uploadLocks.deleteMultipartTrack(lockKey);
|
|
||||||
multipartEntryExists = false;
|
|
||||||
multiPartFileEncResult = null;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
multiPartFileEncResult = multipartEntryExists
|
|
||||||
? await _multiPartUploader.getEncryptionResult(
|
|
||||||
lockKey,
|
|
||||||
mediaUploadData.hashData!.fileHash!,
|
|
||||||
collectionID,
|
|
||||||
)
|
|
||||||
: null;
|
|
||||||
key = multiPartFileEncResult?.key;
|
key = multiPartFileEncResult?.key;
|
||||||
|
|
||||||
// check if the file is already uploaded and can be mapped to existing
|
// check if the file is already uploaded and can be mapped to existing
|
||||||
// uploaded file. If map is found, it also returns the corresponding
|
// uploaded file. If map is found, it also returns the corresponding
|
||||||
// mapped or update file entry.
|
// mapped or update file entry.
|
||||||
@@ -538,9 +521,17 @@ class FileUploader {
|
|||||||
// If the multipart entry exists but the encrypted file doesn't, it means
|
// If the multipart entry exists but the encrypted file doesn't, it means
|
||||||
// that we'll have to reupload as the nonce is lost
|
// that we'll have to reupload as the nonce is lost
|
||||||
if (multipartEntryExists) {
|
if (multipartEntryExists) {
|
||||||
if (!encryptedFileExists) {
|
final bool updateWithDiffKey = isUpdatedFile &&
|
||||||
_logger
|
multiPartFileEncResult != null &&
|
||||||
.warning('encrypted file not found for multipart upload entry');
|
!listEquals(key, multiPartFileEncResult.key);
|
||||||
|
if (!encryptedFileExists || updateWithDiffKey) {
|
||||||
|
if (updateWithDiffKey) {
|
||||||
|
_logger.severe('multiPart update resumed with differentKey');
|
||||||
|
} else {
|
||||||
|
_logger.warning(
|
||||||
|
'multiPart EncryptedFile missing, discard multipart entry',
|
||||||
|
);
|
||||||
|
}
|
||||||
await _uploadLocks.deleteMultipartTrack(lockKey);
|
await _uploadLocks.deleteMultipartTrack(lockKey);
|
||||||
multipartEntryExists = false;
|
multipartEntryExists = false;
|
||||||
multiPartFileEncResult = null;
|
multiPartFileEncResult = null;
|
||||||
|
Reference in New Issue
Block a user