리펙토링: 전체 구조 검토, 개선
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const { ipcMain } = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
|
||||
const EXTS = new Set(['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.tif', '.webp', '.heic', '.heif']);
|
||||
|
||||
@@ -12,7 +13,7 @@ function register() {
|
||||
.map(f => {
|
||||
const fullPath = path.join(folderPath, f);
|
||||
const stat = fs.statSync(fullPath);
|
||||
return { name: f, path: fullPath, mtime: stat.mtimeMs, size: stat.size };
|
||||
return { name: f, path: fullPath, mtime: stat.mtimeMs };
|
||||
})
|
||||
.sort((a, b) => a.name.localeCompare(b.name, 'ko'));
|
||||
return files;
|
||||
@@ -78,7 +79,7 @@ function register() {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const src = files[i].path;
|
||||
const ext = path.extname(files[i].name).toLowerCase();
|
||||
const tmp = path.join(folderPath, `__tmp_rename_${i}_${Date.now()}${ext}`);
|
||||
const tmp = path.join(folderPath, `__tmp_${crypto.randomUUID()}${ext}`);
|
||||
try {
|
||||
fs.renameSync(src, tmp);
|
||||
tmpMap.push({ tmp, ext, idx: i });
|
||||
|
||||
@@ -53,7 +53,7 @@ function register(mainWindow) {
|
||||
return { name: e.name, path: fullPath, hasChildren };
|
||||
})
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
} catch { return []; }
|
||||
} catch { return null; }
|
||||
});
|
||||
|
||||
ipcMain.handle('reveal-folder', (_e, folderPath) => shell.openPath(folderPath));
|
||||
|
||||
Reference in New Issue
Block a user