π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
bye getUint8ArrayView
Manav Rathifa0d1331a81f
diff --git a/web/apps/photos/src/services/detect-type.ts b/web/apps/photos/src/services/detect-type.tsindex bbabf00249..6fd2fd70d2 100644--- a/web/apps/photos/src/services/detect-type.ts+++ b/web/apps/photos/src/services/detect-type.ts@@ -7,7 +7,6 @@ import {import { lowercaseExtension } from "@/next/file";import { CustomError } from "@ente/shared/error";import FileType from "file-type";-import { getUint8ArrayView } from "./readerService";/*** Read the file's initial contents or use the file's name to detect its type.@@ -89,7 +88,7 @@ export const detectFileTypeInfoFromChunk = async (const readInitialChunkOfFile = async (file: File) => {const chunkSizeForTypeDetection = 4100;const chunk = file.slice(0, chunkSizeForTypeDetection);- return await getUint8ArrayView(chunk);+ return new Uint8Array(await chunk.arrayBuffer());};const detectFileTypeFromBuffer = async (buffer: Uint8Array) => {diff --git a/web/apps/photos/src/services/readerService.ts b/web/apps/photos/src/services/readerService.tsindex e30710d5ad..a1195b35d1 100644--- a/web/apps/photos/src/services/readerService.ts+++ b/web/apps/photos/src/services/readerService.ts@@ -1,21 +1,5 @@-import { convertBytesToHumanReadable } from "@/next/file";-import log from "@/next/log";import { ElectronFile } from "@/next/types/file";-export async function getUint8ArrayView(- file: Blob | ElectronFile,-): Promise<Uint8Array> {- try {- return new Uint8Array(await file.arrayBuffer());- } catch (e) {- log.error(- `Failed to read file blob of size ${convertBytesToHumanReadable(file.size)}`,- e,- );- throw e;- }-}-export function getFileStream(file: File, chunkSize: number) {const fileChunkReader = fileChunkReaderMaker(file, chunkSize);@@ -36,6 +20,16 @@ export function getFileStream(file: File, chunkSize: number) {};}+async function* fileChunkReaderMaker(file: File, chunkSize: number) {+ let offset = 0;+ while (offset < file.size) {+ const chunk = file.slice(offset, chunkSize + offset);+ yield new Uint8Array(await chunk.arrayBuffer());+ offset += chunkSize;+ }+ return null;+}+export async function getElectronFileStream(file: ElectronFile,chunkSize: number,@@ -46,14 +40,3 @@ export async function getElectronFileStream(chunkCount,};}--async function* fileChunkReaderMaker(file: File, chunkSize: number) {- let offset = 0;- while (offset < file.size) {- const blob = file.slice(offset, chunkSize + offset);- const fileChunk = await getUint8ArrayView(blob);- yield fileChunk;- offset += chunkSize;- }- return null;-}