Skip to content

armgit / ente

Public Imported from GitHub
0

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

Dedup

Manav Rathifb1d2c800a8f
diff --git a/web/apps/cast/src/utils/file/index.ts b/web/apps/cast/src/utils/file/index.ts
index 8d724feb52..31ed5c577f 100644
--- a/web/apps/cast/src/utils/file/index.ts
+++ b/web/apps/cast/src/utils/file/index.ts
@@ -85,18 +85,6 @@ export async function decryptFile(
}
}
-export function getFileNameWithoutExtension(filename: string) {
- const lastDotPosition = filename.lastIndexOf(".");
- if (lastDotPosition === -1) return filename;
- else return filename.slice(0, lastDotPosition);
-}
-
-export function getFileExtensionWithDot(filename: string) {
- const lastDotPosition = filename.lastIndexOf(".");
- if (lastDotPosition === -1) return "";
- else return filename.slice(lastDotPosition);
-}
-
export function generateStreamFromArrayBuffer(data: Uint8Array) {
return new ReadableStream({
async start(controller: ReadableStreamDefaultController) {
diff --git a/web/apps/photos/src/services/upload/livePhotoService.ts b/web/apps/photos/src/services/upload/livePhotoService.ts
index 025c67e62c..cb0ac93186 100644
--- a/web/apps/photos/src/services/upload/livePhotoService.ts
+++ b/web/apps/photos/src/services/upload/livePhotoService.ts
@@ -1,10 +1,10 @@
+import { encodeLivePhoto } from "@/media/live-photo";
import log from "@/next/log";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { CustomError } from "@ente/shared/error";
import { Remote } from "comlink";
import { FILE_TYPE } from "constants/file";
import { LIVE_PHOTO_ASSET_SIZE_LIMIT } from "constants/upload";
-import { encodeLivePhoto } from "@/media/live-photo";
import { getFileType } from "services/typeDetectionService";
import {
ElectronFile,
@@ -14,12 +14,6 @@ import {
LivePhotoAssets,
ParsedMetadataJSONMap,
} from "types/upload";
-import {
- getFileExtensionWithDot,
- getFileNameWithoutExtension,
- isImageOrVideo,
- splitFilenameAndExtension,
-} from "utils/file";
import { getFileTypeFromExtensionForLivePhotoClustering } from "utils/file/livePhoto";
import { getUint8ArrayView } from "../readerService";
import { extractFileMetadata } from "./fileService";
@@ -304,3 +298,28 @@ function removePotentialLivePhotoSuffix(
return filenameWithoutExtension;
}
}
+
+function getFileNameWithoutExtension(filename: string) {
+ const lastDotPosition = filename.lastIndexOf(".");
+ if (lastDotPosition === -1) return filename;
+ else return filename.slice(0, lastDotPosition);
+}
+
+function getFileExtensionWithDot(filename: string) {
+ const lastDotPosition = filename.lastIndexOf(".");
+ if (lastDotPosition === -1) return "";
+ else return filename.slice(lastDotPosition);
+}
+
+function splitFilenameAndExtension(filename: string): [string, string] {
+ const lastDotPosition = filename.lastIndexOf(".");
+ if (lastDotPosition === -1) return [filename, null];
+ else
+ return [
+ filename.slice(0, lastDotPosition),
+ filename.slice(lastDotPosition + 1),
+ ];
+}
+
+const isImageOrVideo = (fileType: FILE_TYPE) =>
+ [FILE_TYPE.IMAGE, FILE_TYPE.VIDEO].includes(fileType);
diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.ts
index f954016fb6..c1ee834482 100644
--- a/web/apps/photos/src/utils/file/index.ts
+++ b/web/apps/photos/src/utils/file/index.ts
@@ -250,18 +250,6 @@ export async function decryptFile(
}
}
-export function getFileNameWithoutExtension(filename: string) {
- const lastDotPosition = filename.lastIndexOf(".");
- if (lastDotPosition === -1) return filename;
- else return filename.slice(0, lastDotPosition);
-}
-
-export function getFileExtensionWithDot(filename: string) {
- const lastDotPosition = filename.lastIndexOf(".");
- if (lastDotPosition === -1) return "";
- else return filename.slice(lastDotPosition);
-}
-
export function splitFilenameAndExtension(filename: string): [string, string] {
const lastDotPosition = filename.lastIndexOf(".");
if (lastDotPosition === -1) return [filename, null];