Merge pull request #162 from ente-io/export-v3

Export v3
This commit is contained in:
Abhinav Kumar 2023-05-09 11:33:34 +05:30 committed by GitHub
commit f43287df24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 171 additions and 136 deletions

View file

@ -1,7 +1,7 @@
{
"name": "ente",
"productName": "ente",
"version": "1.6.27",
"version": "1.6.28-alpha.1",
"private": true,
"description": "Desktop client for ente.io",
"main": "app/main.js",

View file

@ -12,15 +12,6 @@ export const checkExistsAndCreateDir = async (dirPath: string) => {
}
};
export const checkExistsAndRename = async (
oldDirPath: string,
newDirPath: string
) => {
if (fs.existsSync(oldDirPath)) {
await fs.rename(oldDirPath, newDirPath);
}
};
export const saveStreamToDisk = async (
filePath: string,
fileStream: ReadableStream<Uint8Array>

View file

@ -5,4 +5,4 @@ export async function getDirFiles(dirPath: string) {
const electronFiles = await Promise.all(files.map(getElectronFile));
return electronFiles;
}
export { isFolder } from '../services/fs';
export { isFolder, moveFile, deleteFolder, rename } from '../services/fs';

View file

@ -29,7 +29,6 @@ import { clearElectronStore } from './api/electronStore';
import { openDiskCache, deleteDiskCache } from './api/cache';
import {
checkExistsAndCreateDir,
checkExistsAndRename,
saveStreamToDisk,
saveFileToDisk,
getExportRecord,
@ -45,7 +44,13 @@ import {
openDirectory,
} from './api/common';
import { fixHotReloadNext12 } from './utils/preload';
import { isFolder, getDirFiles } from './api/fs';
import {
isFolder,
getDirFiles,
moveFile,
deleteFolder,
rename,
} from './api/fs';
import { convertHEIC, generateImageThumbnail } from './api/imageProcessor';
import { setupLogging } from './utils/logging';
import {
@ -63,7 +68,6 @@ const windowObject: any = window;
windowObject['ElectronAPIs'] = {
exists,
checkExistsAndCreateDir,
checkExistsAndRename,
saveStreamToDisk,
saveFileToDisk,
selectRootDirectory,
@ -105,4 +109,7 @@ windowObject['ElectronAPIs'] = {
logRendererProcessMemoryUsage,
registerForegroundEventListener,
openDirectory,
moveFile,
deleteFolder,
rename,
};

View file

@ -241,3 +241,40 @@ export async function readTextFile(filePath: string) {
}
return await fs.readFile(filePath, 'utf-8');
}
export async function moveFile(
sourcePath: string,
destinationPath: string
): Promise<void> {
if (!existsSync(sourcePath)) {
throw new Error('File does not exist');
}
if (existsSync(destinationPath)) {
throw new Error('Destination file already exists');
}
// check if destination folder exists
const destinationFolder = path.dirname(destinationPath);
if (!existsSync(destinationFolder)) {
await fs.mkdir(destinationFolder, { recursive: true });
}
await fs.rename(sourcePath, destinationPath);
}
export async function deleteFolder(folderPath: string): Promise<void> {
if (!existsSync(folderPath)) {
return;
}
// check if folder is empty
const files = await fs.readdir(folderPath);
if (files.length > 0) {
throw new Error('Folder is not empty');
}
await fs.rmdir(folderPath);
}
export async function rename(oldPath: string, newPath: string) {
if (!existsSync(oldPath)) {
throw new Error('Path does not exist');
}
await fs.rename(oldPath, newPath);
}

View file

@ -114,7 +114,7 @@ export default function setupIpcComs(
});
ipcMain.handle('open-dir', (_, dirPath) => {
shell.openPath(dirPath);
shell.openPath(path.normalize(dirPath));
});
ipcMain.on('update-and-restart', () => {

2
ui

@ -1 +1 @@
Subproject commit 627cad22e2481258bec9dd6996ea55fe38512672
Subproject commit d0cd90f2715fe3b9c2cd0ce3f422505deb4f5d5d