Dedup
This commit is contained in:
parent
871cb417d6
commit
fb1d2c800a
3 changed files with 26 additions and 31 deletions
|
@ -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) {
|
export function generateStreamFromArrayBuffer(data: Uint8Array) {
|
||||||
return new ReadableStream({
|
return new ReadableStream({
|
||||||
async start(controller: ReadableStreamDefaultController) {
|
async start(controller: ReadableStreamDefaultController) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
import { encodeLivePhoto } from "@/media/live-photo";
|
||||||
import log from "@/next/log";
|
import log from "@/next/log";
|
||||||
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
|
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
|
||||||
import { CustomError } from "@ente/shared/error";
|
import { CustomError } from "@ente/shared/error";
|
||||||
import { Remote } from "comlink";
|
import { Remote } from "comlink";
|
||||||
import { FILE_TYPE } from "constants/file";
|
import { FILE_TYPE } from "constants/file";
|
||||||
import { LIVE_PHOTO_ASSET_SIZE_LIMIT } from "constants/upload";
|
import { LIVE_PHOTO_ASSET_SIZE_LIMIT } from "constants/upload";
|
||||||
import { encodeLivePhoto } from "@/media/live-photo";
|
|
||||||
import { getFileType } from "services/typeDetectionService";
|
import { getFileType } from "services/typeDetectionService";
|
||||||
import {
|
import {
|
||||||
ElectronFile,
|
ElectronFile,
|
||||||
|
@ -14,12 +14,6 @@ import {
|
||||||
LivePhotoAssets,
|
LivePhotoAssets,
|
||||||
ParsedMetadataJSONMap,
|
ParsedMetadataJSONMap,
|
||||||
} from "types/upload";
|
} from "types/upload";
|
||||||
import {
|
|
||||||
getFileExtensionWithDot,
|
|
||||||
getFileNameWithoutExtension,
|
|
||||||
isImageOrVideo,
|
|
||||||
splitFilenameAndExtension,
|
|
||||||
} from "utils/file";
|
|
||||||
import { getFileTypeFromExtensionForLivePhotoClustering } from "utils/file/livePhoto";
|
import { getFileTypeFromExtensionForLivePhotoClustering } from "utils/file/livePhoto";
|
||||||
import { getUint8ArrayView } from "../readerService";
|
import { getUint8ArrayView } from "../readerService";
|
||||||
import { extractFileMetadata } from "./fileService";
|
import { extractFileMetadata } from "./fileService";
|
||||||
|
@ -304,3 +298,28 @@ function removePotentialLivePhotoSuffix(
|
||||||
return filenameWithoutExtension;
|
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);
|
||||||
|
|
|
@ -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] {
|
export function splitFilenameAndExtension(filename: string): [string, string] {
|
||||||
const lastDotPosition = filename.lastIndexOf(".");
|
const lastDotPosition = filename.lastIndexOf(".");
|
||||||
if (lastDotPosition === -1) return [filename, null];
|
if (lastDotPosition === -1) return [filename, null];
|
||||||
|
|
Loading…
Reference in a new issue