From 199df72cf63fdff6e6e901a433a3a2d73cc4f453 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 2 May 2025 13:58:09 +0530 Subject: [PATCH] ign --- web/apps/photos/tests/upload.test.ts | 16 ++++++++-------- web/packages/gallery/services/upload/date.ts | 11 +++++++++++ web/packages/gallery/services/upload/remote.ts | 8 ++++++-- web/packages/gallery/services/upload/takeout.ts | 10 ++++++++++ .../gallery/services/upload/thumbnail.ts | 2 ++ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/web/apps/photos/tests/upload.test.ts b/web/apps/photos/tests/upload.test.ts index a9347f092f..b918f52cc9 100644 --- a/web/apps/photos/tests/upload.test.ts +++ b/web/apps/photos/tests/upload.test.ts @@ -1,18 +1,18 @@ /* eslint-disable @typescript-eslint/dot-notation */ +import { + parseDateFromDigitGroups, + tryParseEpochMicrosecondsFromFileName, +} from "ente-gallery/services/upload/date"; +import { + matchTakeoutMetadata, + metadataJSONMapKeyForJSON, +} from "ente-gallery/services/upload/takeout"; import { FileType } from "ente-media/file-type"; import { getLocalCollections } from "ente-new/photos/services/collections"; import { getLocalFiles, groupFilesByCollectionID, } from "ente-new/photos/services/files"; -import { - parseDateFromDigitGroups, - tryParseEpochMicrosecondsFromFileName, -} from "services/upload/date"; -import { - matchTakeoutMetadata, - metadataJSONMapKeyForJSON, -} from "services/upload/takeout"; import { getUserDetailsV2 } from "services/userService"; const DATE_TIME_PARSING_TEST_FILE_NAMES = [ diff --git a/web/packages/gallery/services/upload/date.ts b/web/packages/gallery/services/upload/date.ts index c1e2abf4da..054fb358bb 100644 --- a/web/packages/gallery/services/upload/date.ts +++ b/web/packages/gallery/services/upload/date.ts @@ -1,3 +1,6 @@ +// TODO: Audit this file +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/ban-ts-comment */ import { nameAndExtension } from "ente-base/file-name"; import log from "ente-base/log"; @@ -35,10 +38,12 @@ const parseEpochMicrosecondsFromFileName = (fileName: string) => { if (fileName.startsWith("IMG-") || fileName.startsWith("VID-")) { // WhatsApp media files // - e.g. "IMG-20171218-WA0028.jpg" + // @ts-ignore date = parseDateFromFusedDateString(fileName.split("-")[1]); } else if (fileName.startsWith("Screenshot_")) { // Screenshots on Android // - e.g. "Screenshot_20181227-152914.jpg" + // @ts-ignore date = parseDateFromFusedDateString( fileName.replaceAll("Screenshot_", ""), ); @@ -58,13 +63,16 @@ const parseEpochMicrosecondsFromFileName = (fileName: string) => { const p = fileName.split("-"); if (p.length > 5) { const dateString = `${p[1]}${p[2]}${p[3]}-${p[4]}${p[5]}${p[6]}`; + // @ts-ignore date = parseDateFromFusedDateString(dateString); } else { const dateString = `${p[1]}${p[2]}${p[3]}-${p[4]}`; + // @ts-ignore date = parseDateFromFusedDateString(dateString); } } + // @ts-ignore if (!date) { const [name] = nameAndExtension(fileName); @@ -89,13 +97,16 @@ const parseEpochMicrosecondsFromFileName = (fileName: string) => { const p = name.split("_"); if (p.length == 3) { const dateString = `${p[0]}-${p[1]}`; + // @ts-ignore date = parseDateFromFusedDateString(dateString); } } } // Generic pattern. + // @ts-ignore if (!date) { + // @ts-ignore date = parseDateFromDigitGroups(fileName); } diff --git a/web/packages/gallery/services/upload/remote.ts b/web/packages/gallery/services/upload/remote.ts index 632532e5c0..3a2250153b 100644 --- a/web/packages/gallery/services/upload/remote.ts +++ b/web/packages/gallery/services/upload/remote.ts @@ -1,3 +1,7 @@ +// TODO: Audit this file +/* eslint-disable */ +// @ts-nocheck + import { authenticatedPublicAlbumsRequestHeaders, authenticatedRequestHeaders, @@ -7,12 +11,12 @@ import { } from "ente-base/http"; import log from "ente-base/log"; import { apiURL, uploaderOrigin } from "ente-base/origins"; -import { EnteFile } from "ente-media/file"; +import { type EnteFile } from "ente-media/file"; import { CustomError, handleUploadError } from "ente-shared/error"; import HTTPService from "ente-shared/network/HTTPService"; import { getToken } from "ente-shared/storage/localStorage/helpers"; import { z } from "zod"; -import { MultipartUploadURLs, UploadFile } from "./upload-service"; +import type { MultipartUploadURLs, UploadFile } from "./upload-service"; /** * A pre-signed URL alongwith the associated object key. diff --git a/web/packages/gallery/services/upload/takeout.ts b/web/packages/gallery/services/upload/takeout.ts index 5ed59bae7d..149f1a0c9c 100644 --- a/web/packages/gallery/services/upload/takeout.ts +++ b/web/packages/gallery/services/upload/takeout.ts @@ -1,3 +1,7 @@ +// TODO: Audit this file +/* eslint-disable @typescript-eslint/ban-ts-comment */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/dot-notation */ /** @file Dealing with the JSON metadata sidecar files */ @@ -161,18 +165,24 @@ const parseMetadataJSONText = (text: string) => { const parsedMetadataJSON: ParsedMetadataJSON = {}; parsedMetadataJSON.creationTime = + // @ts-ignore parseGTTimestamp(metadataJSON["photoTakenTime"]) ?? + // @ts-ignore parseGTTimestamp(metadataJSON["creationTime"]); parsedMetadataJSON.modificationTime = parseGTTimestamp( + // @ts-ignore metadataJSON["modificationTime"], ); parsedMetadataJSON.location = + // @ts-ignore parseGTLocation(metadataJSON["geoData"]) ?? + // @ts-ignore parseGTLocation(metadataJSON["geoDataExif"]); parsedMetadataJSON.description = parseGTNonEmptyString( + // @ts-ignore metadataJSON["description"], ); diff --git a/web/packages/gallery/services/upload/thumbnail.ts b/web/packages/gallery/services/upload/thumbnail.ts index f000d64692..72d3858065 100644 --- a/web/packages/gallery/services/upload/thumbnail.ts +++ b/web/packages/gallery/services/upload/thumbnail.ts @@ -1,3 +1,5 @@ +// TODO: Audit this file +/* eslint-disable @typescript-eslint/prefer-promise-reject-errors */ import log from "ente-base/log"; import { type Electron } from "ente-base/types/ipc"; import * as ffmpeg from "ente-gallery/services/ffmpeg";