Use method from shared pkd

This commit is contained in:
Neeraj Gupta 2024-01-20 12:17:35 +05:30
parent dff2a38de9
commit cde75e3a37
5 changed files with 4 additions and 16 deletions

View file

@ -1,6 +1,6 @@
import { logError } from '@ente/shared/sentry';
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
import { ElectronFile } from 'types/upload';
import { convertBytesToHumanReadable } from 'utils/file/size';
export async function getUint8ArrayView(
file: Blob | ElectronFile

View file

@ -9,7 +9,7 @@ import { getFileExtension } from 'utils/file';
import { logError } from '@ente/shared/sentry';
import { getUint8ArrayView } from './readerService';
import FileType, { FileTypeResult } from 'file-type';
import { convertBytesToHumanReadable } from 'utils/file/size';
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
function getFileSize(file: File | ElectronFile) {
return file.size;

View file

@ -3,10 +3,10 @@ import { CustomError } from 'utils/error';
import { retryAsyncFunction } from 'utils/network';
import { DedicatedConvertWorker } from 'worker/convert.worker';
import { ComlinkWorker } from 'utils/comlink/comlinkWorker';
import { convertBytesToHumanReadable } from 'utils/file/size';
import { getDedicatedConvertWorker } from 'utils/comlink/ComlinkConvertWorker';
import { logError } from '@ente/shared/sentry';
import { addLogLine } from '@ente/shared/logging';
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
const WORKER_POOL_SIZE = 2;
const MAX_CONVERSION_IN_PARALLEL = 1;

View file

@ -29,7 +29,6 @@ import { VISIBILITY_STATE } from 'types/magicMetadata';
import { isArchivedFile, updateMagicMetadata } from 'utils/magicMetadata';
import { CustomError } from 'utils/error';
import { convertBytesToHumanReadable } from './size';
import ComlinkCryptoWorker from 'utils/comlink/ComlinkCryptoWorker';
import {
deleteFromTrash,
@ -45,6 +44,7 @@ import { moveToHiddenCollection } from 'services/collectionService';
import { getData, LS_KEYS } from '@ente/shared/storage/localStorage';
import { User } from '@ente/shared/user/types';
import { addLogLine, addLocalLog } from '@ente/shared/logging';
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
// import ElectronFSService from 'services/electron/fs';
// import { getFileExportPath, getUniqueFileExportName } from 'utils/export';

View file

@ -1,12 +0,0 @@
export function convertBytesToHumanReadable(
bytes: number,
precision = 2
): string {
if (bytes === 0 || isNaN(bytes)) {
return '0 MB';
}
const i = Math.floor(Math.log(bytes) / Math.log(1024));
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
return (bytes / Math.pow(1024, i)).toFixed(precision) + ' ' + sizes[i];
}