Use method from shared pkd
This commit is contained in:
parent
dff2a38de9
commit
cde75e3a37
5 changed files with 4 additions and 16 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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];
|
||||
}
|
Loading…
Add table
Reference in a new issue