Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix issue

Abhinavea29af8e98d4
diff --git a/apps/photos/src/services/upload/fileService.ts b/apps/photos/src/services/upload/fileService.ts
index c62a14df70..ddeeb0ea0e 100644
--- a/apps/photos/src/services/upload/fileService.ts
+++ b/apps/photos/src/services/upload/fileService.ts
@@ -17,7 +17,6 @@ import { getFileNameSize } from '@ente/shared/logging/web';
import { encryptFiledata } from './encryptionService';
import {
MAX_FILE_NAME_LENGTH_GOOGLE_EXPORT,
- NULL_PARSED_METADATA_JSON,
extractMetadata,
getClippedMetadataJSONMapKeyForFile,
getMetadataJSONMapKeyForFile,
@@ -82,8 +81,7 @@ export async function extractFileMetadata(
rawFile: File | ElectronFile
): Promise<ExtractMetadataResult> {
let key = getMetadataJSONMapKeyForFile(collectionID, rawFile.name);
- let googleMetadata: ParsedMetadataJSON =
- parsedMetadataJSONMap.get(key) ?? NULL_PARSED_METADATA_JSON;
+ let googleMetadata: ParsedMetadataJSON = parsedMetadataJSONMap.get(key);
if (!googleMetadata && key.length > MAX_FILE_NAME_LENGTH_GOOGLE_EXPORT) {
key = getClippedMetadataJSONMapKeyForFile(collectionID, rawFile.name);
@@ -96,7 +94,7 @@ export async function extractFileMetadata(
fileTypeInfo
);
- for (const [key, value] of Object.entries(googleMetadata)) {
+ for (const [key, value] of Object.entries(googleMetadata ?? {})) {
if (!value) {
continue;
}
diff --git a/apps/photos/src/services/upload/metadataService.ts b/apps/photos/src/services/upload/metadataService.ts
index 5f7cb42eab..035842c6ec 100644
--- a/apps/photos/src/services/upload/metadataService.ts
+++ b/apps/photos/src/services/upload/metadataService.ts
@@ -23,7 +23,7 @@ import { DedicatedCryptoWorker } from '@ente/shared/crypto/internal/crypto.worke
import { FilePublicMagicMetadataProps } from 'types/file';
import { splitFilenameAndExtension } from 'utils/file';
-export const NULL_PARSED_METADATA_JSON: ParsedMetadataJSON = {
+const NULL_PARSED_METADATA_JSON: ParsedMetadataJSON = {
creationTime: null,
modificationTime: null,
...NULL_LOCATION,
diff --git a/apps/photos/tests/upload.test.ts b/apps/photos/tests/upload.test.ts
index 376cb5c6dc..75cb4ac185 100644
--- a/apps/photos/tests/upload.test.ts
+++ b/apps/photos/tests/upload.test.ts
@@ -5,6 +5,7 @@ import { groupFilesBasedOnCollectionID } from 'utils/file';
import { FILE_TYPE } from 'constants/file';
import { tryToParseDateTime } from '@ente/shared/time';
import {
+ MAX_FILE_NAME_LENGTH_GOOGLE_EXPORT,
getClippedMetadataJSONMapKeyForFile,
getMetadataJSONMapKeyForFile,
getMetadataJSONMapKeyForJSON,
@@ -82,8 +83,8 @@ const FILE_NAME_TO_JSON_NAME = [
jsonFilename: 'IMG2021021(4455)74722.jpg(1).json',
},
{
- filename: 'IMG2021021(json)74722(1).jpg',
- jsonFilename: 'IMG2021021(json)74722.jpg(1).json',
+ filename: 'IMG2021021.json74722(1).jpg',
+ jsonFilename: 'IMG2021021.json74722.jpg(1).json',
},
{
filename: 'IMG2021021(1)74722(1).jpg',
@@ -396,7 +397,10 @@ function mappingFileAndJSONFileCheck() {
jsonFilename
);
let fileNameGeneratedKey = getMetadataJSONMapKeyForFile(0, filename);
- if (fileNameGeneratedKey !== jsonFileNameGeneratedKey) {
+ if (
+ fileNameGeneratedKey !== jsonFileNameGeneratedKey &&
+ filename.length > MAX_FILE_NAME_LENGTH_GOOGLE_EXPORT
+ ) {
fileNameGeneratedKey = getClippedMetadataJSONMapKeyForFile(
0,
filename