Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web] Retain original's file creation time on edits

Manav Rathi708109f5e411
diff --git a/web/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx b/web/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx
index de5afca30b..848bf2e462 100644
--- a/web/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx
+++ b/web/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx
@@ -475,15 +475,14 @@ const ImageEditorOverlay = (props: IProps) => {
);
const editedFile = await getEditedFile();
- const file = {
- uploadItem: editedFile,
- localID: 1,
- collectionID: props.file.collectionID,
- };
uploadManager.prepareForNewUpload();
uploadManager.showUploadProgressDialog();
- uploadManager.uploadItems([file], [collection]);
+ uploadManager.uploadFile(
+ editedFile,
+ collection,
+ props.file.metadata.creationTime,
+ );
setFileURL(null);
props.onClose();
props.closePhotoViewer();
diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.ts
index 700dbc9738..1a4dcb3908 100644
--- a/web/apps/photos/src/services/upload/uploadManager.ts
+++ b/web/apps/photos/src/services/upload/uploadManager.ts
@@ -450,6 +450,33 @@ class UploadManager {
return this.uiService.hasFilesInResultList();
}
+ /**
+ * Upload a single file to the given collection.
+ *
+ * @param file A web {@link File} object representing the file to upload.
+ *
+ * @param collection The {@link Collection} in which the file should be added.
+ *
+ * @param creationTime The timestamp (unix epoch microseconds) to use as the
+ * `creationTime` of the newly created {@link EnteFile}.
+ */
+ public async uploadFile(
+ file: File,
+ collection: Collection,
+ creationTime: number,
+ ) {
+ const item = {
+ uploadItem: file,
+ localID: 1,
+ collectionID: collection.id,
+ };
+ this.parsedMetadataJSONMap.set(
+ getMetadataJSONMapKeyForJSON(collection.id, file.name),
+ { creationTime },
+ );
+ return this.uploadItems([item], [collection]);
+ }
+
private abortIfCancelled = () => {
if (uploadCancelService.isUploadCancelationRequested()) {
throw Error(CustomError.UPLOAD_CANCELLED);