fix(library): resolve root folder rename, open in explorer, open at location centering, UPDATE rescan bug, and optimize scan RAM memory usage

This commit is contained in:
2026-10-07 19:16:03 +07:00
parent af76b46c3e
commit 9bfb39be91
5 changed files with 82 additions and 21 deletions
+26 -2
View File
@@ -2,11 +2,11 @@ import { recipeFile } from './recipeFile';
import { sendVerificationMail } from './mailer';
import { placeName } from './place';
import Fastify, { type FastifyReply, type FastifyRequest } from 'fastify';
import { spawn, spawnSync } from 'node:child_process';
import { exec, spawn, spawnSync } from 'node:child_process';
import { createHash, randomBytes } from 'node:crypto';
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, unlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { basename, join } from 'node:path';
import { basename, dirname, join } from 'node:path';
import {
DATA_DIR,
MAX_PHOTO_BYTES,
@@ -420,6 +420,30 @@ async function lookupGeo(ip: string): Promise<GeoPlace | null> {
// ---- routes ----
app.get('/api/health', async () => ({ ok: true }));
// Native file manager launcher (Open in window explorer)
app.post('/api/open-explorer', async (req, reply) => {
const b = bodyOf(req);
if (!b || typeof b.path !== 'string') return reply.status(400).send({ ok: false, error: 'Invalid path' });
const rawPath = b.path.trim();
if (!rawPath) return reply.status(400).send({ ok: false, error: 'Path empty' });
const platform = process.platform;
try {
if (platform === 'win32') {
const winPath = rawPath.replace(/\//g, '\\');
exec(`explorer.exe /select,"${winPath}"`);
} else if (platform === 'darwin') {
exec(`open -R "${rawPath}"`);
} else {
const dir = dirname(rawPath);
exec(`xdg-open "${dir}"`);
}
return reply.send({ ok: true });
} catch (err: any) {
return reply.status(500).send({ ok: false, error: String(err?.message || err) });
}
});
// The counter's one write. Public and unauthenticated by design: it is fired by
// a beacon from every page, so it must never be a way to probe who is signed in
// — it answers 204 whatever happens and echoes nothing back.