|
@@ -1,11 +1,15 @@
|
|
import { DataStream } from 'types/upload';
|
|
import { DataStream } from 'types/upload';
|
|
-import ImportService from 'services/importService';
|
|
|
|
|
|
+import ElectronAPIs from '@ente/shared/electron';
|
|
import { FILE_READER_CHUNK_SIZE, PICKED_UPLOAD_TYPE } from 'constants/upload';
|
|
import { FILE_READER_CHUNK_SIZE, PICKED_UPLOAD_TYPE } from 'constants/upload';
|
|
import { getFileStream, getElectronFileStream } from 'services/readerService';
|
|
import { getFileStream, getElectronFileStream } from 'services/readerService';
|
|
import { getFileNameSize } from '@ente/shared/logging/web';
|
|
import { getFileNameSize } from '@ente/shared/logging/web';
|
|
import isElectron from 'is-electron';
|
|
import isElectron from 'is-electron';
|
|
import { getImportSuggestion } from 'utils/upload';
|
|
import { getImportSuggestion } from 'utils/upload';
|
|
|
|
|
|
|
|
+// This was for used to verify that converting from the browser readable stream
|
|
|
|
+// to the node readable stream correctly handles files that align on the 4 MB
|
|
|
|
+// data boundary. This expects a zip file containing random files of various
|
|
|
|
+// sizes starting from 1M to 20M.
|
|
export const testZipFileReading = async () => {
|
|
export const testZipFileReading = async () => {
|
|
try {
|
|
try {
|
|
if (!isElectron()) {
|
|
if (!isElectron()) {
|
|
@@ -17,12 +21,12 @@ export const testZipFileReading = async () => {
|
|
'upload test failed NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH missing'
|
|
'upload test failed NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH missing'
|
|
);
|
|
);
|
|
}
|
|
}
|
|
- const files = await ImportService.getElectronFilesFromGoogleZip(
|
|
|
|
|
|
+ const files = await ElectronAPIs.getElectronFilesFromGoogleZip(
|
|
process.env.NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH
|
|
process.env.NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH
|
|
);
|
|
);
|
|
if (!files?.length) {
|
|
if (!files?.length) {
|
|
throw Error(
|
|
throw Error(
|
|
- `testZipFileReading Check failed ❌
|
|
|
|
|
|
+ `testZipFileReading Check failed ❌
|
|
No files selected`
|
|
No files selected`
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -73,6 +77,8 @@ export const testZipFileReading = async () => {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+// This was used when fixing a bug around handling a zip file that has a photo
|
|
|
|
+// at the root.
|
|
export const testZipWithRootFileReadingTest = async () => {
|
|
export const testZipWithRootFileReadingTest = async () => {
|
|
try {
|
|
try {
|
|
if (!isElectron()) {
|
|
if (!isElectron()) {
|
|
@@ -84,7 +90,7 @@ export const testZipWithRootFileReadingTest = async () => {
|
|
'upload test failed NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH missing'
|
|
'upload test failed NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH missing'
|
|
);
|
|
);
|
|
}
|
|
}
|
|
- const files = await ImportService.getElectronFilesFromGoogleZip(
|
|
|
|
|
|
+ const files = await ElectronAPIs.getElectronFilesFromGoogleZip(
|
|
process.env.NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH
|
|
process.env.NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH
|
|
);
|
|
);
|
|
|
|
|