feat(ui): aggiunge anteprima desktop dei file non smistati

This commit is contained in:
2026-03-16 10:11:59 +01:00
parent 164959acaf
commit 3a567c390c
5 changed files with 198 additions and 1 deletions

View File

@@ -46,8 +46,58 @@ async function getUnroutedTarget(fileName) {
};
}
async function listFilesRecursively(rootDir) {
const files = [];
async function walk(currentDir) {
let entries;
try {
entries = await fs.readdir(currentDir, { withFileTypes: true });
} catch {
return;
}
for (const entry of entries) {
const fullPath = path.join(currentDir, entry.name);
if (entry.isDirectory()) {
await walk(fullPath);
continue;
}
if (!entry.isFile()) {
continue;
}
const stats = await fs.stat(fullPath).catch(() => null);
if (!stats) {
continue;
}
files.push({
name: entry.name,
relativePath: path.relative(rootDir, fullPath),
size: stats.size,
updatedAt: stats.mtime.toISOString(),
});
}
}
await walk(rootDir);
files.sort((a, b) => a.relativePath.localeCompare(b.relativePath, 'it'));
return files;
}
async function listUnroutedFiles() {
const directory = await resolveUnroutedDir();
const files = await listFilesRecursively(directory);
return { directory, files };
}
module.exports = {
getUnroutedTarget,
resolveUnroutedDir,
listUnroutedFiles,
PRIMARY_UNROUTED_DIR,
HOME_UNROUTED_DIR,
};