commit
17aaecbcc7
5 changed files with 43 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "ente",
|
"name": "ente",
|
||||||
"productName": "ente",
|
"productName": "ente",
|
||||||
"version": "1.6.15-beta.1",
|
"version": "1.6.16",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Desktop client for ente.io",
|
"description": "Desktop client for ente.io",
|
||||||
"main": "app/main.js",
|
"main": "app/main.js",
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as fs from 'promise-fs';
|
||||||
import { ElectronFile } from '../types';
|
import { ElectronFile } from '../types';
|
||||||
import StreamZip from 'node-stream-zip';
|
import StreamZip from 'node-stream-zip';
|
||||||
import { Readable } from 'stream';
|
import { Readable } from 'stream';
|
||||||
|
import { logError } from './logging';
|
||||||
|
|
||||||
// https://stackoverflow.com/a/63111390
|
// https://stackoverflow.com/a/63111390
|
||||||
export const getDirFilePaths = async (dirPath: string) => {
|
export const getDirFilePaths = async (dirPath: string) => {
|
||||||
|
@ -97,31 +98,50 @@ export const getZipFileStream = async (
|
||||||
const done = {
|
const done = {
|
||||||
current: false,
|
current: false,
|
||||||
};
|
};
|
||||||
|
const inProgress = {
|
||||||
|
current: false,
|
||||||
|
};
|
||||||
let resolveObj: (value?: any) => void = null;
|
let resolveObj: (value?: any) => void = null;
|
||||||
let rejectObj: (reason?: any) => void = null;
|
let rejectObj: (reason?: any) => void = null;
|
||||||
stream.on('readable', () => {
|
stream.on('readable', () => {
|
||||||
if (resolveObj) {
|
try {
|
||||||
const chunk = stream.read(FILE_STREAM_CHUNK_SIZE) as Buffer;
|
if (resolveObj) {
|
||||||
|
inProgress.current = true;
|
||||||
if (chunk) {
|
const chunk = stream.read(FILE_STREAM_CHUNK_SIZE) as Buffer;
|
||||||
resolveObj(new Uint8Array(chunk));
|
if (chunk) {
|
||||||
resolveObj = null;
|
resolveObj(new Uint8Array(chunk));
|
||||||
|
resolveObj = null;
|
||||||
|
}
|
||||||
|
inProgress.current = false;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
rejectObj(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
done.current = true;
|
try {
|
||||||
|
done.current = true;
|
||||||
|
if (resolveObj && !inProgress.current) {
|
||||||
|
resolveObj(null);
|
||||||
|
resolveObj = null;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
rejectObj(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
stream.on('error', (e) => {
|
stream.on('error', (e) => {
|
||||||
done.current = true;
|
try {
|
||||||
|
done.current = true;
|
||||||
if (rejectObj) {
|
if (rejectObj) {
|
||||||
|
rejectObj(e);
|
||||||
|
rejectObj = null;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
rejectObj(e);
|
rejectObj(e);
|
||||||
rejectObj = null;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const readStreamData = () => {
|
const readStreamData = async () => {
|
||||||
return new Promise<Uint8Array>((resolve, reject) => {
|
return new Promise<Uint8Array>((resolve, reject) => {
|
||||||
const chunk = stream.read(FILE_STREAM_CHUNK_SIZE) as Buffer;
|
const chunk = stream.read(FILE_STREAM_CHUNK_SIZE) as Buffer;
|
||||||
|
|
||||||
|
@ -145,6 +165,7 @@ export const getZipFileStream = async (
|
||||||
controller.close();
|
controller.close();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
logError(e, 'readableStream pull failed');
|
||||||
controller.close();
|
controller.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,11 +15,15 @@ export const getSavedFilePaths = (type: FILE_PATH_TYPE) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getZipEntryAsElectronFile(
|
export async function getZipEntryAsElectronFile(
|
||||||
|
zipName: string,
|
||||||
zip: StreamZip.StreamZipAsync,
|
zip: StreamZip.StreamZipAsync,
|
||||||
entry: StreamZip.ZipEntry
|
entry: StreamZip.ZipEntry
|
||||||
): Promise<ElectronFile> {
|
): Promise<ElectronFile> {
|
||||||
return {
|
return {
|
||||||
path: entry.name,
|
path: path
|
||||||
|
.join(zipName, entry.name)
|
||||||
|
.split(path.sep)
|
||||||
|
.join(path.posix.sep),
|
||||||
name: path.basename(entry.name),
|
name: path.basename(entry.name),
|
||||||
size: entry.size,
|
size: entry.size,
|
||||||
lastModified: entry.time,
|
lastModified: entry.time,
|
||||||
|
@ -58,6 +62,7 @@ export const getElectronFilesFromGoogleZip = async (filePath: string) => {
|
||||||
const zip = new StreamZip.async({
|
const zip = new StreamZip.async({
|
||||||
file: filePath,
|
file: filePath,
|
||||||
});
|
});
|
||||||
|
const zipName = path.basename(filePath, '.zip');
|
||||||
|
|
||||||
const entries = await zip.entries();
|
const entries = await zip.entries();
|
||||||
const files: ElectronFile[] = [];
|
const files: ElectronFile[] = [];
|
||||||
|
@ -65,7 +70,7 @@ export const getElectronFilesFromGoogleZip = async (filePath: string) => {
|
||||||
for (const entry of Object.values(entries)) {
|
for (const entry of Object.values(entries)) {
|
||||||
const basename = path.basename(entry.name);
|
const basename = path.basename(entry.name);
|
||||||
if (entry.isFile && basename.length > 0 && basename[0] !== '.') {
|
if (entry.isFile && basename.length > 0 && basename[0] !== '.') {
|
||||||
files.push(await getZipEntryAsElectronFile(zip, entry));
|
files.push(await getZipEntryAsElectronFile(zipName, zip, entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function handleUpdates(mainWindow: BrowserWindow) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function setupTrayItem(mainWindow: BrowserWindow) {
|
export function setupTrayItem(mainWindow: BrowserWindow) {
|
||||||
const iconName = isPlatformMac
|
const iconName = isPlatform('mac')
|
||||||
? 'taskbar-icon-Template.png'
|
? 'taskbar-icon-Template.png'
|
||||||
: 'taskbar-icon.png';
|
: 'taskbar-icon.png';
|
||||||
const trayImgPath = path.join(
|
const trayImgPath = path.join(
|
||||||
|
|
2
ui
2
ui
|
@ -1 +1 @@
|
||||||
Subproject commit 5e486434ade454de49f8fd98874e9181afc4d99b
|
Subproject commit a8c520a4b0ff90279cffedf41b9e8f8564d9a753
|
Loading…
Add table
Reference in a new issue