Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: show media file sizes and recycle deleted media

[._.]/ Adam Eivy532d5a3a8a93
diff --git a/client/src/components/media/MediaCard.jsx b/client/src/components/media/MediaCard.jsx
index dcf256f3d6..7bcbab41d8 100644
--- a/client/src/components/media/MediaCard.jsx
+++ b/client/src/components/media/MediaCard.jsx
@@ -5,7 +5,7 @@ import AddToCollectionMenu from './AddToCollectionMenu';
import PinToMoodBoardMenu from './PinToMoodBoardMenu';
import InlineConfirmRow from '../ui/InlineConfirmRow';
import { loraDisplayName } from './normalize';
-import { formatDurationMs } from '../../utils/formatters';
+import { formatBytes, formatDurationMs } from '../../utils/formatters';
import { assetDownloadUrl } from '../../lib/standaloneDownload.js';
// Equal cells. `flex-1` on Remix used to eat the first row, which pushed
@@ -220,6 +220,9 @@ function MediaCard({
{item.steps && <span className="px-1.5 py-0.5 bg-port-border text-gray-400 rounded">{item.steps}st</span>}
{item.numFrames && <span className="px-1.5 py-0.5 bg-port-border text-gray-400 rounded">{item.numFrames}f</span>}
{item.fps && <span className="px-1.5 py-0.5 bg-port-border text-gray-400 rounded">{item.fps}fps</span>}
+ {item.fileSizeBytes != null && (
+ <span title="Original file size" className="px-1.5 py-0.5 bg-port-border text-gray-400 rounded">{formatBytes(item.fileSizeBytes)}</span>
+ )}
{item.seed != null && <span className="px-1.5 py-0.5 bg-port-border text-gray-400 rounded">seed {item.seed}</span>}
{/* How long this render took, once the queue picked it up (see the
renderMs contract in normalize.js). Absent renders no chip at all,
@@ -250,7 +253,7 @@ function MediaCard({
<InlineConfirmRow
question={`Delete this ${isVideo ? 'video' : 'image'}?`}
confirmText="Delete"
- confirmTitle="Permanently delete"
+ confirmTitle="Move files to Trash or Recycle Bin on the PortOS host"
onConfirm={() => { setConfirmingDelete(false); onDelete(item); }}
onCancel={() => setConfirmingDelete(false)}
/>
diff --git a/client/src/components/media/MediaCard.test.jsx b/client/src/components/media/MediaCard.test.jsx
index 91d48d7a41..004fcf3739 100644
--- a/client/src/components/media/MediaCard.test.jsx
+++ b/client/src/components/media/MediaCard.test.jsx
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, act } from '@testing-library/react';
import MediaCard from './MediaCard';
+import { normalizeImage, normalizeVideo } from './normalize';
const socketHandlers = new Map();
vi.mock('../../services/socket', () => ({
@@ -230,3 +231,18 @@ describe('MediaCard render-time chip', () => {
expect(container.querySelector('[title^="Render time"]')).toBeNull();
});
});
+
+describe('shared media-card file size', () => {
+ it.each(['image', 'video'])('shows the actual %s file size beside the geometry chips', kind => {
+ const normalize = kind === 'image' ? normalizeImage : normalizeVideo;
+ render(<MediaCard item={normalize({ ...imageItem, id: 'example-clip', width: 640, height: 480, fps: kind === 'video' ? 24 : undefined, fileSizeBytes: 1572864 })} />);
+ expect(screen.getByTitle('Original file size')).toHaveTextContent('1.5 MB');
+ expect(screen.getByText('640×480').parentElement).toContainElement(screen.getByTitle('Original file size'));
+ });
+ it('omits unknown sizes while retaining a measured zero', () => {
+ const { rerender } = render(<MediaCard item={imageItem} />);
+ expect(screen.queryByTitle('Original file size')).not.toBeInTheDocument();
+ rerender(<MediaCard item={{ ...imageItem, fileSizeBytes: 0 }} />);
+ expect(screen.getByTitle('Original file size')).toHaveTextContent('0 B');
+ });
+});
diff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsx
index 27cfdcef22..8d2653656b 100644
--- a/client/src/components/media/MediaLightbox.jsx
+++ b/client/src/components/media/MediaLightbox.jsx
@@ -18,7 +18,7 @@ import { i2vReferenceModeLabel } from '../../lib/videoReferenceModes';
import useFocusTrap from '../../hooks/useFocusTrap.js';
import { copyToClipboard } from '../../lib/clipboard';
import { IMAGE_GEN_MODE } from '../../lib/imageGenBackends';
-import { formatDateTime, formatDateNumeric, formatDurationMs } from '../../utils/formatters';
+import { formatDateTime, formatDateNumeric, formatDurationMs, formatBytes } from '../../utils/formatters';
import AttributionList from './AttributionList';
import SentPromptPanel from './SentPromptPanel';
@@ -302,6 +302,7 @@ export default function MediaLightbox({
['Execution', executionLabel],
['Frames', item.numFrames],
['FPS', item.fps],
+ ['File size', item.fileSizeBytes != null ? formatBytes(item.fileSizeBytes) : null],
// What the conditioning image promised (#4874). Recorded on the render only
// when it wasn't the default, so this row appears exactly on the clips whose
// opening frame was generated rather than reproduced — the one fact the
diff --git a/client/src/components/media/normalize.js b/client/src/components/media/normalize.js
index 76dbcf8880..cd9704b52f 100644
--- a/client/src/components/media/normalize.js
+++ b/client/src/components/media/normalize.js
@@ -32,6 +32,7 @@ export function normalizeImage(i) {
const modelId = i.modelId || i.model || (i.mode && i.mode !== IMAGE_GEN_MODE.LOCAL ? i.mode : null);
return {
kind: 'image',
+ fileSizeBytes: Number.isFinite(i.fileSizeBytes) && i.fileSizeBytes >= 0 ? i.fileSizeBytes : null,
key: `image:${i.filename}`,
filename: i.filename,
previewUrl: originalUrl,
@@ -130,6 +131,7 @@ export function normalizeVideo(v) {
const loraNames = (pickLoraFilenames(v) || []).filter(Boolean);
return {
kind: 'video',
+ fileSizeBytes: Number.isFinite(v.fileSizeBytes) && v.fileSizeBytes >= 0 ? v.fileSizeBytes : null,
key: `video:${v.id}`,
posterSec: v.posterSec ?? null,
id: v.id,
diff --git a/docs/DEPS.md b/docs/DEPS.md
index 0fbae410f4..9906117794 100644
--- a/docs/DEPS.md
+++ b/docs/DEPS.md
@@ -42,6 +42,7 @@ Before removing a Tier 3 candidate, run a transitive-dep check (`npm ls <pkg>`).
| `sharp` | 1 | KEEP | image processing | Native, widely-audited |
| `socket.io` | 1 | KEEP | realtime | Foundational |
| `socket.io-client` | 1 | KEEP | server-to-client | Paired with socket.io |
+| `trash` | 2 | KEEP | Recoverable image/video history deletion (`server/lib/trashFiles.js`) | Native macOS Trash and Windows Recycle Bin helpers plus Linux XDG trash; avoids maintaining platform deletion/restore semantics. Lazy-loaded, literal paths only, no permanent-delete fallback |
| `undici` | 1 | KEEP | HTTP client | Node core team project |
| `ws` | 1 | KEEP | remote desktop + browser WebSockets | Foundational WebSocket transport; also used transitively by Socket.IO |
| `zod` | 1 | KEEP | input validation | Widely-audited |
diff --git a/docs/IMAGE_GALLERY.md b/docs/IMAGE_GALLERY.md
index 23b16520d7..cf4f721987 100644
--- a/docs/IMAGE_GALLERY.md
+++ b/docs/IMAGE_GALLERY.md
@@ -71,3 +71,26 @@ restart the first window to account for shifted offsets; collection bulk selecti
says Select loaded while more pages remain. Deep-linked previews resolve directly.
Sidecar enrichment, recovered prompts, imported images, and peer asset arrivals
refresh the existing image-index hook after their authoritative writes.
+
+## File sizes and recoverable deletion
+
+Image and video gallery rows include `fileSizeBytes` when the original file can
+be measured. Compact pages keep it, and the shared `MediaCard` displays it next
+to resolution/FPS using `formatBytes`; the lightbox uses the same formatter.
+The server measures only the selected page with bounded concurrency, so older
+records need no backfill. Missing or unreadable files omit the field rather
+than reporting a false zero. A measured empty file reports zero bytes.
+
+Deleting gallery images or video-history entries moves their originals,
+sidecars, thumbnails and video audio masters to the operating system's Trash
+or Recycle Bin on the **PortOS server machine**. Video deletion also recycles
+a `<filename>.metadata.json` snapshot of that video's history record, preserving
+its prompt/settings without moving the shared history store. Temporary render
+cleanup still permanently removes temporary files.
+
+Recycling errors fail the request; there is no permanent-delete fallback.
+History and derived index rows are retired only after the file operation
+confirms the files are gone. Native recycling can partially succeed, so after
+a failure some files may already be in Trash; a retry processes remaining
+files. Restore files using the host OS. Restoring a video file does not
+automatically recreate its PortOS history entry or collection membership.
diff --git a/server/lib/README.md b/server/lib/README.md
index 8ca4caf1d5..c546f1e80f 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -917,3 +917,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
- `auditWorkflow.js`: versioned extended Deep execution and historical certification classification.
| `musicDesignerValidation.js` | Non-transforming authored input schemas and character limits for Music Designer composition and routes. |
+
+- `mediaFileInfo.js`: `withMediaFileSize(kind, record)` / `withMediaFileSizes(items, kind?)` add current original-file byte sizes to bounded image/video pages; missing or unreadable files have no size.
+- `trashFiles.js`: `trashFiles(paths)` moves existing literal paths to the host OS Trash/Recycle Bin, guards test data, and propagates failures without permanent-delete fallback.
+- `nativeTrash.js`: `moveToNativeTrash(paths)` executes the pinned package native recycling helpers on macOS/Windows with hidden windows and a deadline; Linux uses the package XDG adapter. No local-directory or permanent-delete fallback.
diff --git a/server/lib/index.js b/server/lib/index.js
index 495af59e3e..85040e9171 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -317,6 +317,9 @@ export * from './scaffoldSnippets.js';
export * from './failureLogging.js';
export * from './faultIsolatedEmitter.js';
export * from './fileCore.js';
+export * from './mediaFileInfo.js';
+export * from './trashFiles.js';
+export * from './nativeTrash.js';
export * as fileUtils from './fileUtils.js';
export * from './fileWriteQueue.js';
export * from './forgeIssueCli.js';
diff --git a/server/lib/mediaFileInfo.js b/server/lib/mediaFileInfo.js
new file mode 100644
index 0000000000..e0d330da55
--- /dev/null
+++ b/server/lib/mediaFileInfo.js
@@ -0,0 +1,25 @@
+/** Actual original-media sizes, enriched only after a page has been selected. */
+import { stat } from 'node:fs/promises';
+import { join } from 'node:path';
+import { PATHS } from './paths.js';
+import { isTopLevelEntryName } from './pathSafety.js';
+import { mapWithConcurrency } from './mapWithConcurrency.js';
+
+export async function withMediaFileSize(kind, record) {
+ if (!record) return record;
+ // Stored metadata can outlive a replacement or a missing file. Never present
+ // its old size as a current measurement, or an unavailable size as zero.
+ const data = { ...record };
+ delete data.fileSizeBytes;
+ if (!['image', 'video'].includes(kind) || !isTopLevelEntryName(data.filename)) return data;
+ const directory = kind === 'image' ? PATHS.images : PATHS.videos;
+ const info = await stat(join(directory, data.filename)).catch(() => null);
+ return info?.isFile() ? { ...data, fileSizeBytes: info.size } : data;
+}
+
+/** Accepts plain records of one kind or the mixed gallery's { kind, data } rows. */
+export function withMediaFileSizes(items, kind) {
+ return mapWithConcurrency(items, 4, async item => kind
+ ? withMediaFileSize(kind, item)
+ : { ...item, data: await withMediaFileSize(item.kind, item.data) });
+}
diff --git a/server/lib/nativeTrash.js b/server/lib/nativeTrash.js
new file mode 100644
index 0000000000..5ad45a5df1
--- /dev/null
+++ b/server/lib/nativeTrash.js
@@ -0,0 +1,18 @@
+/** OS recycling adapter using the pinned trash package's native helper assets. */
+import { promisify } from 'node:util';
+import { fileURLToPath } from 'node:url';
+
+export async function moveToNativeTrash(paths) {
+ const binary = { darwin: 'macos-trash', win32: 'windows-trash.exe' }[process.platform];
+ if (binary) {
+ // Own the spawn: Windows must stay console-free, and macOS must not use
+ // the package's fallback to a working-directory .Trash outside the OS bin.
+ const command = fileURLToPath(new URL(`./lib/${binary}`, import.meta.resolve('trash')));
+ const { execFile } = await import('./childProcess.js');
+ await promisify(execFile)(command, paths, { timeout: 30_000 });
+ return;
+ }
+ if (process.platform !== 'linux') throw new Error('Native trash is unavailable on this platform');
+ const { default: trash } = await import('trash');
+ await trash(paths, { glob: false });
+}
diff --git a/server/lib/nativeTrash.test.js b/server/lib/nativeTrash.test.js
new file mode 100644
index 0000000000..1789b87e86
--- /dev/null
+++ b/server/lib/nativeTrash.test.js
@@ -0,0 +1,36 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { existsSync } from 'node:fs';
+import { pinPlatform } from './testHelper.js';
+import { moveToNativeTrash } from './nativeTrash.js';
+
+const state = vi.hoisted(() => ({ execFile: vi.fn(), trash: vi.fn() }));
+vi.mock('./childProcess.js', () => ({ execFile: (...args) => state.execFile(...args) }));
+vi.mock('trash', () => ({ default: state.trash }));
+let restore;
+afterEach(() => { restore?.(); vi.resetAllMocks(); });
+
+describe('native recycling adapter', () => {
+ it.each([['darwin', 'macos-trash'], ['win32', 'windows-trash.exe']])('uses a hidden, bounded native helper on %s', async (platform, binary) => {
+ restore = pinPlatform(platform);
+ state.execFile.mockImplementation((_command, _args, _options, callback) => { callback(null, '', ''); });
+ await moveToNativeTrash(['/synthetic/scene[1].png']);
+ expect(state.execFile).toHaveBeenCalledWith(expect.stringContaining(binary), ['/synthetic/scene[1].png'], { timeout: 30_000 }, expect.any(Function));
+ expect(existsSync(state.execFile.mock.calls[0][0])).toBe(true);
+ expect(state.trash).not.toHaveBeenCalled();
+ });
+
+ it('uses literal paths for Linux XDG trash', async () => {
+ restore = pinPlatform('linux');
+ state.trash.mockResolvedValueOnce();
+ await moveToNativeTrash(['/synthetic/scene[1].png']);
+ expect(state.trash).toHaveBeenCalledWith(['/synthetic/scene[1].png'], { glob: false });
+ expect(state.execFile).not.toHaveBeenCalled();
+ });
+});
+
+it('does not fall back when the native macOS operation is rejected', async () => {
+ restore = pinPlatform('darwin');
+ state.execFile.mockImplementation((_command, _args, _options, callback) => { callback(new Error('trash unavailable')); });
+ await expect(moveToNativeTrash(['/synthetic/scene.png'])).rejects.toThrow('trash unavailable');
+ expect(state.trash).not.toHaveBeenCalled();
+});
diff --git a/server/lib/trashFiles.js b/server/lib/trashFiles.js
new file mode 100644
index 0000000000..8ab73bd52e
--- /dev/null
+++ b/server/lib/trashFiles.js
@@ -0,0 +1,37 @@
+/** Recoverable deletion for user-owned files; temporary cleanup still uses unlink. */
+import { moveToNativeTrash } from './nativeTrash.js';
+import { lstat } from 'node:fs/promises';
+import { ServerError } from './errorHandler.js';
+import { isVitestRunner } from './runtimeEnv.js';
+
+export async function trashFiles(paths) {
+ const existing = [];
+ for (const path of [...new Set(paths.filter(Boolean))]) {
+ if (isVitestRunner()) {
+ const { assertNotRealDataWrite } = await import('./testDataIsolation.js');
+ assertNotRealDataWrite(path, 'trash');
+ }
+ const info = await lstat(path).catch(error => {
+ if (error.code === 'ENOENT') return null;
+ throw error;
+ });
+ if (info?.isDirectory()) throw new ServerError('Media deletion requires a file', { status: 400, code: 'INVALID_MEDIA_FILE' });
+ if (info) existing.push(path);
+ }
+ if (!existing.length) return;
+ // Literal paths only; the native helper owns its OS-specific recycling.
+ await moveToNativeTrash(existing).then(async () => {
+ for (const path of existing) {
+ await lstat(path).then(() => {
+ throw new Error('File remains after trash operation');
+ }, error => {
+ if (error.code !== 'ENOENT') throw error;
+ });
+ }
+ }).catch(error => {
+ console.error(`❌ Media trash failed (${error.code || 'TRASH_FAILED'})`);
+ throw new ServerError('Could not move media to Trash or Recycle Bin. No permanent deletion was attempted.', {
+ status: 503, code: 'MEDIA_TRASH_FAILED',
+ });
+ });
+}
diff --git a/server/lib/trashFiles.test.js b/server/lib/trashFiles.test.js
new file mode 100644
index 0000000000..20e1f54b41
--- /dev/null
+++ b/server/lib/trashFiles.test.js
@@ -0,0 +1,56 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { mkdtemp, mkdir, writeFile, readFile, rename, rm } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { basename, join } from 'node:path';
+import { trashFiles } from './trashFiles.js';
+
+const { trash, probe } = vi.hoisted(() => ({ trash: vi.fn(), probe: vi.fn() }));
+vi.mock('node:fs/promises', async original => {
+ const actual = await original();
+ return { ...actual, lstat: probe.mockImplementation(actual.lstat) };
+});
+vi.mock('./nativeTrash.js', () => ({ moveToNativeTrash: trash }));
+let root;
+beforeEach(async () => {
+ probe.mockImplementation((await vi.importActual('node:fs/promises')).lstat);
+ root = await mkdtemp(join(tmpdir(), 'portos-trash-contract-'));
+});
+afterEach(async () => { vi.restoreAllMocks(); await rm(root, { recursive: true, force: true }); });
+
+describe('recoverable file deletion', () => {
+ it('moves literal originals and sidecars into a recoverable bin, skipping absent derivatives', async () => {
+ const bin = join(root, 'bin');
+ await mkdir(bin);
+ const image = join(root, 'scene[1].png');
+ const metadata = join(root, 'scene[1].metadata.json');
+ await writeFile(image, 'pixels');
+ await writeFile(metadata, '{"prompt":"example"}');
+ trash.mockImplementationOnce(async paths => { for (const path of paths) await rename(path, join(bin, basename(path))); });
+ await trashFiles([image, image, metadata, join(root, 'missing.webp')]);
+ expect(trash).toHaveBeenLastCalledWith([image, metadata]);
+ expect(await readFile(join(bin, basename(image)), 'utf8')).toBe('pixels');
+ expect(JSON.parse(await readFile(join(bin, basename(metadata)), 'utf8'))).toEqual({ prompt: 'example' });
+ });
+
+ it.each(['rejected', 'false success'])('refuses %s recycling without permanently deleting the file', async failure => {
+ const file = join(root, 'clip.mp4');
+ await writeFile(file, 'video');
+ if (failure === 'rejected') trash.mockRejectedValueOnce(new Error('native trash unavailable'));
+ else trash.mockResolvedValueOnce();
+ vi.spyOn(console, 'error').mockImplementation(() => {});
+ await expect(trashFiles([file])).rejects.toMatchObject({ code: 'MEDIA_TRASH_FAILED' });
+ expect(await readFile(file, 'utf8')).toBe('video');
+ });
+});
+
+it('refuses an unreadable post-trash probe instead of inferring the file is gone', async () => {
+ const file = join(root, 'clip.mp4');
+ const binFile = join(root, 'recycled.mp4');
+ await writeFile(file, 'video');
+ const actual = await vi.importActual('node:fs/promises');
+ probe.mockImplementationOnce(actual.lstat).mockRejectedValueOnce(Object.assign(new Error('permission denied'), { code: 'EACCES' }));
+ trash.mockImplementationOnce(async () => { await rename(file, binFile); });
+ vi.spyOn(console, 'error').mockImplementation(() => {});
+ await expect(trashFiles([file])).rejects.toMatchObject({ code: 'MEDIA_TRASH_FAILED' });
+ expect(await readFile(binFile, 'utf8')).toBe('video');
+});
diff --git a/server/package-lock.json b/server/package-lock.json
index f51e919b4e..4a5c86dc14 100644
--- a/server/package-lock.json
+++ b/server/package-lock.json
@@ -25,6 +25,7 @@
"socket.io": "4.8.4",
"socket.io-client": "4.8.4",
"three": "0.186.1",
+ "trash": "10.1.1",
"undici": "8.12.1",
"ws": "8.22.0",
"zod": "4.6.7"
@@ -929,6 +930,41 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
+ "node_modules/@nodelib/fs.scandir": {
+ "version": "2.1.5",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
+ "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.stat": "2.0.5",
+ "run-parallel": "^1.1.9"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/@nodelib/fs.stat": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
+ "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/@nodelib/fs.walk": {
+ "version": "1.2.8",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
+ "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.scandir": "2.1.5",
+ "fastq": "^1.6.0"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
"node_modules/@novnc/novnc": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/@novnc/novnc/-/novnc-1.7.0.tgz",
@@ -1305,12 +1341,45 @@
"license": "MIT",
"peer": true
},
+ "node_modules/@sindresorhus/df": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/df/-/df-3.1.1.tgz",
+ "integrity": "sha512-SME/vtXaJcnQ/HpeV6P82Egy+jThn11IKfwW8+/XVoRD0rmPHVTeKMtww1oWdVnMykzVPjmrDN9S8NBndPEHCQ==",
+ "license": "MIT",
+ "dependencies": {
+ "execa": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/@sindresorhus/merge-streams": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz",
+ "integrity": "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/@socket.io/component-emitter": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
"integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==",
"license": "MIT"
},
+ "node_modules/@stroncium/procfs": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/@stroncium/procfs/-/procfs-1.2.1.tgz",
+ "integrity": "sha512-X1Iui3FUNZP18EUvysTHxt+Avu2nlVzyf90YM8OYgP6SGzTzzX/0JgObfO1AQQDzuZtNNz29bVh8h5R97JrjxA==",
+ "license": "CC0-1.0",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/@tootallnate/quickjs-emscripten": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz",
@@ -1780,6 +1849,18 @@
"url": "https://paulmillr.com/funding/"
}
},
+ "node_modules/chunkify": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/chunkify/-/chunkify-5.0.0.tgz",
+ "integrity": "sha512-G8dj/3/Gm+1yL4oWSdwIxihZWFlgC4V2zYtIApacI0iPIRKBHlBGOGAiDUBZgrj4H8MBA8g8fPFwnJrWF3wl7Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/cli-tableau": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/cli-tableau/-/cli-tableau-2.0.1.tgz",
@@ -1941,6 +2022,20 @@
"integrity": "sha512-/f6gpQuxDaqXu+1kwQYSckUglPaOrHdbIlBAu0YuW8/Cdb45XwXYNUBXg3r/9Mo6n540Kn/smKcZWko5x99KrQ==",
"license": "MIT"
},
+ "node_modules/cross-spawn": {
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
+ "license": "MIT",
+ "dependencies": {
+ "path-key": "^3.1.0",
+ "shebang-command": "^2.0.0",
+ "which": "^2.0.1"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
"node_modules/culori": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/culori/-/culori-4.0.2.tgz",
@@ -2062,6 +2157,15 @@
"node": ">= 0.8"
}
},
+ "node_modules/end-of-stream": {
+ "version": "1.4.5",
+ "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
+ "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
+ "license": "MIT",
+ "dependencies": {
+ "once": "^1.4.0"
+ }
+ },
"node_modules/engine.io": {
"version": "6.6.11",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.11.tgz",
@@ -2267,6 +2371,26 @@
"integrity": "sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==",
"license": "MIT"
},
+ "node_modules/execa": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-2.1.0.tgz",
+ "integrity": "sha512-Y/URAVapfbYy2Xp/gb6A0E7iR8xeqOCXsuuaoMn7A5PzrXUK84E1gyiEfq0wQd/GHA6GsoHWwhNq8anb0mleIw==",
+ "license": "MIT",
+ "dependencies": {
+ "cross-spawn": "^7.0.0",
+ "get-stream": "^5.0.0",
+ "is-stream": "^2.0.0",
+ "merge-stream": "^2.0.0",
+ "npm-run-path": "^3.0.0",
+ "onetime": "^5.1.0",
+ "p-finally": "^2.0.0",
+ "signal-exit": "^3.0.2",
+ "strip-final-newline": "^2.0.0"
+ },
+ "engines": {
+ "node": "^8.12.0 || >=9.7.0"
+ }
+ },
"node_modules/expect-type": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz",
@@ -2335,12 +2459,37 @@
"follow-redirects": "^1.14.0"
}
},
+ "node_modules/fast-glob": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
+ "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.stat": "^2.0.2",
+ "@nodelib/fs.walk": "^1.2.3",
+ "glob-parent": "^5.1.2",
+ "merge2": "^1.3.0",
+ "micromatch": "^4.0.8"
+ },
+ "engines": {
+ "node": ">=8.6.0"
+ }
+ },
"node_modules/fast-json-patch": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/fast-json-patch/-/fast-json-patch-3.1.1.tgz",
"integrity": "sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ==",
"license": "MIT"
},
+ "node_modules/fastq": {
+ "version": "1.20.3",
+ "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.3.tgz",
+ "integrity": "sha512-XKv5nnLs6nLF71NgiKJLIZFLkPyIEuOselLG7ujZnGrRfQK8HpvY+WqKhAJUAdLomwVHErVS4LfxFlPq0/FTAw==",
+ "license": "ISC",
+ "dependencies": {
+ "reusify": "^1.0.4"
+ }
+ },
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
@@ -2559,6 +2708,21 @@
"node": ">= 0.4"
}
},
+ "node_modules/get-stream": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
+ "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
+ "license": "MIT",
+ "dependencies": {
+ "pump": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/get-uri": {
"version": "6.0.5",
"resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.5.tgz",
@@ -2585,6 +2749,26 @@
"node": ">= 6"
}
},
+ "node_modules/globby": {
+ "version": "14.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-14.1.0.tgz",
+ "integrity": "sha512-0Ia46fDOaT7k4og1PDW4YbodWWr3scS2vAr2lTbsplOt2WkKp0vQbkI9wKis/T5LV/dqPjO3bpS/z6GTJB82LA==",
+ "license": "MIT",
+ "dependencies": {
+ "@sindresorhus/merge-streams": "^2.1.0",
+ "fast-glob": "^3.3.3",
+ "ignore": "^7.0.3",
+ "path-type": "^6.0.0",
+ "slash": "^5.1.0",
+ "unicorn-magic": "^0.3.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/google-auth-library": {
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-11.0.2.tgz",
@@ -2751,6 +2935,15 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/ignore": {
+ "version": "7.0.12",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz",
+ "integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 4"
+ }
+ },
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -2787,6 +2980,21 @@
"node": ">=8"
}
},
+ "node_modules/is-docker": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
+ "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==",
+ "license": "MIT",
+ "bin": {
+ "is-docker": "cli.js"
+ },
+ "engines": {
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -2808,6 +3016,24 @@
"node": ">=0.10.0"
}
},
+ "node_modules/is-inside-container": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",
+ "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==",
+ "license": "MIT",
+ "dependencies": {
+ "is-docker": "^3.0.0"
+ },
+ "bin": {
+ "is-inside-container": "cli.js"
+ },
+ "engines": {
+ "node": ">=14.16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
@@ -2817,12 +3043,57 @@
"node": ">=0.12.0"
}
},
+ "node_modules/is-path-inside": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz",
+ "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/is-promise": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
"license": "MIT"
},
+ "node_modules/is-stream": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
+ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/is-wsl": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz",
+ "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==",
+ "license": "MIT",
+ "dependencies": {
+ "is-inside-container": "^1.0.0"
+ },
+ "engines": {
+ "node": ">=16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/isexe": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
+ "license": "ISC"
+ },
"node_modules/js-tokens": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz",
@@ -3256,6 +3527,46 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/merge-stream": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
+ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
+ "license": "MIT"
+ },
+ "node_modules/merge2": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
+ "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/micromatch": {
+ "version": "4.0.8",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
+ "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
+ "license": "MIT",
+ "dependencies": {
+ "braces": "^3.0.3",
+ "picomatch": "^2.3.1"
+ },
+ "engines": {
+ "node": ">=8.6"
+ }
+ },
+ "node_modules/micromatch/node_modules/picomatch": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
+ "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
"node_modules/mime-db": {
"version": "1.54.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
@@ -3281,6 +3592,50 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/mimic-fn": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
+ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/mount-point": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/mount-point/-/mount-point-3.0.0.tgz",
+ "integrity": "sha512-jAhfD7ZCG+dbESZjcY1SdFVFqSJkh/yGbdsifHcPkvuLRO5ugK0Ssmd9jdATu29BTd4JiN+vkpMzVvsUgP3SZA==",
+ "license": "MIT",
+ "dependencies": {
+ "@sindresorhus/df": "^1.0.1",
+ "pify": "^2.3.0",
+ "pinkie-promise": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/mount-point/node_modules/@sindresorhus/df": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/df/-/df-1.0.1.tgz",
+ "integrity": "sha512-1Hyp7NQnD/u4DSxR2DGW78TF9k7R0wZ8ev0BpMAIzA6yTQSHqNb5wTuvtcPYf4FWbVse2rW7RgDsyL8ua2vXHw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/move-file": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/move-file/-/move-file-4.1.0.tgz",
+ "integrity": "sha512-YE06K9XLIvMlqSfoZTl32qvbZLPgL70Za41wS8pEhsSOhy71xz2fn8J07nuz/LEEtPSuUzLUFGAJSx499eKDSw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -3406,6 +3761,18 @@
"node": ">=0.10.0"
}
},
+ "node_modules/npm-run-path": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-3.1.0.tgz",
+ "integrity": "sha512-Dbl4A/VfiVGLgQv29URL9xshU8XDY1GeLy+fsaZ1AA8JDSfjvr5P5+pzRbWqRSBxk6/DW7MIh8lTM/PaGnP2kg==",
+ "license": "MIT",
+ "dependencies": {
+ "path-key": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@@ -3471,6 +3838,51 @@
"wrappy": "1"
}
},
+ "node_modules/onetime": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
+ "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
+ "license": "MIT",
+ "dependencies": {
+ "mimic-fn": "^2.1.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/os-homedir": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
+ "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/p-finally": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-2.0.1.tgz",
+ "integrity": "sha512-vpm09aKwq6H9phqRQzecoDpD8TmVyGw70qmWlyq5onxY7tqyTTFVvxMykxQSQKILBSFlbXpypIw2T1Ml7+DDtw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/p-map": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.1.1.tgz",
+ "integrity": "sha512-6Lh3jQPLthYujSrlw6ccWXBGZTkoTCz27Hd92g79LH/kjAbgoEu0t442cCCNbegPSJsA0lwDX8z0bcKtkpA32g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/pac-proxy-agent": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz",
@@ -3512,6 +3924,15 @@
"node": ">= 0.8"
}
},
+ "node_modules/path-key": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/path-to-regexp": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz",
@@ -3522,6 +3943,18 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/path-type": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/path-type/-/path-type-6.0.0.tgz",
+ "integrity": "sha512-Vj7sf++t5pBD637NSfkxpHSMfWaeig5+DKWLhcqIYx6mWQz5hdJTGDVMQiJcw1ZYkhs7AazKDGpRVji1LJCZUQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/pg": {
"version": "8.23.1",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.23.1.tgz",
@@ -3644,6 +4077,36 @@
"node": ">=18"
}
},
+ "node_modules/pify": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
+ "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/pinkie": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz",
+ "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/pinkie-promise": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
+ "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==",
+ "license": "MIT",
+ "dependencies": {
+ "pinkie": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/playwright-core": {
"version": "1.64.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz",
@@ -3837,6 +4300,18 @@
"node": ">=0.10.0"
}
},
+ "node_modules/powershell-utils": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.2.1.tgz",
+ "integrity": "sha512-C+y9x90UElAddDZmV4qOx9W53B61PO7cIqWz2dQsWlwswuq4mr8NEwytdGKboYbQlGZ3awrkTeNvcZiZNHnQ8A==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/proxy-addr": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
@@ -3879,6 +4354,16 @@
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
"license": "MIT"
},
+ "node_modules/pump": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz",
+ "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==",
+ "license": "MIT",
+ "dependencies": {
+ "end-of-stream": "^1.1.0",
+ "once": "^1.3.1"
+ }
+ },
"node_modules/qs": {
"version": "6.16.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
@@ -3895,6 +4380,26 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/queue-microtask": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
+ "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ],
+ "license": "MIT"
+ },
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -3932,6 +4437,16 @@
"url": "https://paulmillr.com/funding/"
}
},
+ "node_modules/reusify": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz",
+ "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==",
+ "license": "MIT",
+ "engines": {
+ "iojs": ">=1.0.0",
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/rolldown": {
"version": "1.2.14",
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.14.tgz",
@@ -3983,6 +4498,29 @@
"node": ">= 18"
}
},
+ "node_modules/run-parallel": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
+ "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "queue-microtask": "^1.2.2"
+ }
+ },
"node_modules/run-series": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/run-series/-/run-series-1.1.9.tgz",
@@ -4141,6 +4679,27 @@
}
}
},
+ "node_modules/shebang-command": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
+ "license": "MIT",
+ "dependencies": {
+ "shebang-regex": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/shebang-regex": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/side-channel": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
@@ -4213,6 +4772,24 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/signal-exit": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
+ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
+ "license": "ISC"
+ },
+ "node_modules/slash": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz",
+ "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=14.16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
@@ -4394,6 +4971,15 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/strip-final-newline": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
+ "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@@ -4480,6 +5066,29 @@
"node": ">=0.6"
}
},
+ "node_modules/trash": {
+ "version": "10.1.1",
+ "resolved": "https://registry.npmjs.org/trash/-/trash-10.1.1.tgz",
+ "integrity": "sha512-L/mu8sfblMwaS+exj1MxpmihlIRwVQyB6ieKuTTmBJG0lXWBPfx3pMGQG8i3NT/S8vvNZrflDUOp+j0o7Cnxzw==",
+ "license": "MIT",
+ "dependencies": {
+ "@stroncium/procfs": "^1.2.1",
+ "chunkify": "^5.0.0",
+ "globby": "^14.1.0",
+ "is-path-inside": "^4.0.0",
+ "move-file": "^4.1.0",
+ "p-map": "^7.0.3",
+ "powershell-utils": "^0.2.0",
+ "wsl-utils": "^0.4.0",
+ "xdg-trashdir": "^3.1.0"
+ },
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
@@ -4546,6 +5155,18 @@
"integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",
"license": "MIT"
},
+ "node_modules/unicorn-magic": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.3.0.tgz",
+ "integrity": "sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@@ -4561,6 +5182,18 @@
"integrity": "sha512-XdVKMF4SJ0nP/O7XIPB0JwAEuT9lDIYnNsK8yGVe43y0AWoKeJNdv3ZNWh7ksJ6KqQFjOO6ox/VEitLnaVNufw==",
"license": "BSD"
},
+ "node_modules/user-home": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz",
+ "integrity": "sha512-KMWqdlOcjCYdtIJpicDSFBQ8nFwS2i9sslAd6f4+CBGcU4gist2REnr2fxj2YocvJFxSF3ZOHLYLVZnUxv4BZQ==",
+ "license": "MIT",
+ "dependencies": {
+ "os-homedir": "^1.0.0"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
@@ -4741,6 +5374,21 @@
"node": ">= 8"
}
},
+ "node_modules/which": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
+ "license": "ISC",
+ "dependencies": {
+ "isexe": "^2.0.0"
+ },
+ "bin": {
+ "node-which": "bin/node-which"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
"node_modules/why-is-node-running": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz",
@@ -4781,6 +5429,58 @@
}
}
},
+ "node_modules/wsl-utils": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.4.0.tgz",
+ "integrity": "sha512-9YmF+2sFEd+T7TkwlmE337F0IVzfDvDknhtpBQxxXzEOfgPphGlFYpyx0cTuCIFj8/p+sqwBYAeGxOMNSzPPDA==",
+ "license": "MIT",
+ "dependencies": {
+ "is-wsl": "^3.1.0",
+ "powershell-utils": "^0.1.0"
+ },
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/wsl-utils/node_modules/powershell-utils": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.1.0.tgz",
+ "integrity": "sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/xdg-basedir": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz",
+ "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/xdg-trashdir": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/xdg-trashdir/-/xdg-trashdir-3.1.0.tgz",
+ "integrity": "sha512-N1XQngeqMBoj9wM4ZFadVV2MymImeiFfYD+fJrNlcVcOHsJFFQe7n3b+aBoTPwARuq2HQxukfzVpQmAk1gN4sQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@sindresorhus/df": "^3.1.1",
+ "mount-point": "^3.0.0",
+ "user-home": "^2.0.0",
+ "xdg-basedir": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/xmlhttprequest-ssl": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.1.2.tgz",
diff --git a/server/package.json b/server/package.json
index f66eba0dc3..e9f7e98442 100644
--- a/server/package.json
+++ b/server/package.json
@@ -39,6 +39,7 @@
"socket.io": "4.8.4",
"socket.io-client": "4.8.4",
"three": "0.186.1",
+ "trash": "10.1.1",
"undici": "8.12.1",
"ws": "8.22.0",
"zod": "4.6.7"
diff --git a/server/routes/imageGen.test.js b/server/routes/imageGen.test.js
index 539fecbe19..7caf9a09dc 100644
--- a/server/routes/imageGen.test.js
+++ b/server/routes/imageGen.test.js
@@ -186,7 +186,7 @@ vi.mock('../lib/pythonSetup.js', () => ({
// Stat the python binary to key the cache. Override per-test for mtime
// changes; default to a stable mtime so the cache HIT path works.
-const mockStat = vi.fn(async () => ({ mtimeMs: 1_700_000_000_000 }));
+const mockStat = vi.fn(async () => ({ mtimeMs: 1_700_000_000_000, isFile: () => false }));
vi.mock('fs/promises', async (importOriginal) => {
const actual = await importOriginal();
return { ...actual, stat: (path) => mockStat(path) };
diff --git a/server/routes/musicVideoTakes.test.js b/server/routes/musicVideoTakes.test.js
index a968dc9bde..80f7dac66e 100644
--- a/server/routes/musicVideoTakes.test.js
+++ b/server/routes/musicVideoTakes.test.js
@@ -1,3 +1,8 @@
+// Keep the filesystem half real without touching the host's Trash.
+vi.mock('../lib/nativeTrash.js', () => ({ moveToNativeTrash: async paths => {
+ const { unlink } = await import('node:fs/promises');
+ for (const path of paths) await unlink(path);
+} }));
/**
* Music Video scene takes + external-asset handoff routes (#8965), exercised
* through the real router and the real file-backed project store. Covers the
diff --git a/server/routes/videoGen.js b/server/routes/videoGen.js
index 13f30eedfd..303fbcce06 100644
--- a/server/routes/videoGen.js
+++ b/server/routes/videoGen.js
@@ -6,6 +6,7 @@
* extraction, ffmpeg stitching).
*/
+import { withMediaFileSizes } from '../lib/mediaFileInfo.js';
import { Router } from 'express';
import { updateVideoPoster, createSharingCopy } from '../services/videoGen/poster.js';
import { basename } from 'path';
@@ -1192,7 +1193,7 @@ const updatePromptSchema = z.object({ prompt: z.string().max(8000) });
const visibilitySchema = z.object({ hidden: z.boolean() });
router.get('/history', asyncHandler(async (_req, res) => {
- res.json(await loadHistory());
+ res.json(await withMediaFileSizes(await loadHistory(), 'video'));
}));
// One history entry by id (#4165) — see videoHistoryRead.js.
diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.js
index 3773f4723a..9db88cb6c7 100644
--- a/server/routes/videoGen.test.js
+++ b/server/routes/videoGen.test.js
@@ -295,6 +295,7 @@ vi.mock('fs', () => ({
existsSync: vi.fn(() => true),
}));
vi.mock('fs/promises', () => ({
+ stat: vi.fn(async () => { throw Object.assign(new Error('not found'), { code: 'ENOENT' }); }),
unlink: fsMock.unlink,
// The route stages multipart uploads to data/uploads/ via copyFile. Stub
// the copy so tests that simulate req.file don't actually touch disk.
diff --git a/server/routes/videoHistoryRead.js b/server/routes/videoHistoryRead.js
index de05472753..b7dda890c2 100644
--- a/server/routes/videoHistoryRead.js
+++ b/server/routes/videoHistoryRead.js
@@ -1,6 +1,7 @@
// One-record video-history read, shared by the video-gen router and the
// isolated collection-audit fixture so both exercise the same production
// handler without importing the generation stack.
+import { withMediaFileSize } from '../lib/mediaFileInfo.js';
import { z } from 'zod';
import { asyncHandler, ServerError, failValidation } from '../lib/errorHandler.js';
@@ -30,7 +31,7 @@ export function createVideoHistoryItemRead(getHistoryItem = async (id) => (await
if (!parsed.success) failValidation(parsed);
const query = historyReadQuerySchema.safeParse(req.query);
if (!query.success) failValidation(query);
- const entry = await getHistoryItem(parsed.data);
+ const entry = await withMediaFileSize('video', await getHistoryItem(parsed.data));
if (!entry) throw new ServerError('Not found', { status: 404, code: 'NOT_FOUND' });
// Hosted clips may omit geometry. Opt-in playback callers measure the same source the render measures.
if (query.data.geometry === 'true' && !(entry.numFrames && entry.fps && entry.width && entry.height)) {
diff --git a/server/services/imageGen/deleteImage.test.js b/server/services/imageGen/deleteImage.test.js
index bf1f0bc0bc..c1b4acb6bc 100644
--- a/server/services/imageGen/deleteImage.test.js
+++ b/server/services/imageGen/deleteImage.test.js
@@ -1,7 +1,7 @@
/**
* Gallery image delete → media-asset-index delete hook (#2738).
*
- * deleteImage unlinks real files, so PATHS.images is redirected at a temp
+ * deleteImage moves real files, so PATHS.images is redirected at a temp
* gallery (same pattern as saveUploadedGalleryImage.test.js) — this suite must
* never touch the repo's real data/images. The index module is mocked: the
* contract under test is the WIRING (the delete path calls the hook, with the
@@ -34,19 +34,15 @@ vi.mock('../../lib/pythonSetup.js', () => ({
const unindexImage = vi.fn(async () => {});
vi.mock('../mediaAssetIndex/index.js', () => ({ unindexImage }));
-// Real fs/promises, except tests can make unlink fail (simulating an
-// EACCES/EBUSY gallery, which deleteImage swallows, leaving the file on disk)
-// and make the post-delete stat probe fail (simulating an unreadable dir).
-let unlinkImpl = null;
-let statImpl = null;
-vi.mock('fs/promises', async () => {
- const actual = await vi.importActual('fs/promises');
- return {
- ...actual,
- unlink: async (...args) => (unlinkImpl ? unlinkImpl(...args) : actual.unlink(...args)),
- stat: async (...args) => (statImpl ? statImpl(...args) : actual.stat(...args)),
- };
-});
+// The native adapter moves into a fixture-owned bin, never the host Trash.
+let trashError = null;
+vi.mock('../../lib/nativeTrash.js', () => ({ moveToNativeTrash: async paths => {
+ if (trashError) throw trashError;
+ const { rename, mkdir } = await vi.importActual('fs/promises');
+ const bin = join(tmpRoot, 'trash');
+ await mkdir(bin, { recursive: true });
+ for (const path of paths) await rename(path, join(bin, path.split(/[\\/]/).pop()));
+} }));
let tmpRoot;
let priorRegistryEnv;
@@ -69,8 +65,8 @@ afterAll(() => {
beforeEach(() => {
vi.clearAllMocks();
- unlinkImpl = null;
- statImpl = null;
+ trashError = null;
+ rmSync(join(tmpRoot, 'trash'), { recursive: true, force: true });
rmSync(imagesDir, { recursive: true, force: true });
});
@@ -92,6 +88,8 @@ describe('deleteImage → media asset index delete hook', () => {
expect(res).toEqual({ ok: true });
expect(existsSync(join(imagesDir, 'img-1.png'))).toBe(false);
expect(existsSync(thumbnail)).toBe(false);
+ expect(existsSync(join(tmpRoot, 'trash', 'img-1.png'))).toBe(true);
+ expect(existsSync(join(tmpRoot, 'trash', 'img-1.metadata.json'))).toBe(true);
// The ref must be the gallery filename — the key the index wrote the row under.
expect(unindexImage).toHaveBeenCalledWith('img-1.png');
});
@@ -109,33 +107,14 @@ describe('deleteImage → media asset index delete hook', () => {
errSpy.mockRestore();
});
- it('keeps the index row when the file survives the delete (no undercount)', async () => {
- // deleteImage swallows unlink errors, so an EACCES/EBUSY gallery leaves the
- // image on disk and still listed by listGallery(). Unindexing it here would
- // swap the overcount this issue fixed for an undercount of a LIVE image.
+ it('preserves the image, metadata and index when recycling fails', async () => {
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
- unlinkImpl = async () => { throw Object.assign(new Error('EACCES: permission denied'), { code: 'EACCES' }); };
+ trashError = Object.assign(new Error('EACCES'), { code: 'EACCES' });
seedImage('img-3.png');
-
- await expect(deleteImage('img-3.png')).resolves.toEqual({ ok: true });
+ await expect(deleteImage('img-3.png')).rejects.toMatchObject({ code: 'MEDIA_TRASH_FAILED' });
expect(existsSync(join(imagesDir, 'img-3.png'))).toBe(true);
+ expect(existsSync(join(imagesDir, 'img-3.metadata.json'))).toBe(true);
expect(unindexImage).not.toHaveBeenCalled();
- expect(errSpy).toHaveBeenCalledWith(expect.stringContaining('not confirmed gone'));
- errSpy.mockRestore();
- });
-
- it('keeps the index row when the probe itself fails (unknown != absent)', async () => {
- // An unreadable gallery dir must not read as "the file is gone". existsSync
- // would return false here and retire a live row; only a definitive ENOENT
- // may unindex.
- const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
- unlinkImpl = async () => { throw Object.assign(new Error('EACCES'), { code: 'EACCES' }); };
- statImpl = async () => { throw Object.assign(new Error('EACCES'), { code: 'EACCES' }); };
- seedImage('img-4.png');
-
- await expect(deleteImage('img-4.png')).resolves.toEqual({ ok: true });
- expect(unindexImage).not.toHaveBeenCalled();
- expect(errSpy).toHaveBeenCalledWith(expect.stringContaining('EACCES'));
errSpy.mockRestore();
});
});
diff --git a/server/services/imageGen/local.js b/server/services/imageGen/local.js
index 3b1e41e60f..d99f3f5f66 100644
--- a/server/services/imageGen/local.js
+++ b/server/services/imageGen/local.js
@@ -20,6 +20,7 @@ import { existsSync, watch as fsWatch } from 'fs';
import { join, dirname, resolve as resolvePath, sep as PATH_SEP, basename } from 'path';
import { tmpdir } from 'os';
import { randomUUID } from 'crypto';
+import { trashFiles } from '../../lib/trashFiles.js';
import { atomicWrite, assertSafeFilename, detectImageFormat, ensureDir, listDirectoryByExtension, PATHS, safeJSONParse, resolveImageInputPath, tryReadFile, rmGuarded, unlinkGuarded } from '../../lib/fileUtils.js';
import { extractPngGenerationMetadata, extractPngGenerationMetadataFile } from '../../lib/pngMetadata.js';
import { ServerError } from '../../lib/errorHandler.js';
@@ -1460,6 +1461,7 @@ export async function listGallery() {
path: `/data/images/${f}`,
createdAt: metadata.createdAt || s.birthtime.toISOString(),
...metadata,
+ fileSizeBytes: s.size,
};
},
});
@@ -1468,39 +1470,20 @@ export async function listGallery() {
export async function deleteImage(filename) {
assertGalleryFilename(filename);
- return withBackupAssetPublication(async () => {
- await unlinkGuarded(join(PATHS.imageThumbnails, filename.replace(/\.png$/i, '.webp'))).catch(() => {});
- await unlinkGuarded(join(PATHS.images, filename)).catch(() => {});
- await unlinkGuarded(join(PATHS.images, filename.replace('.png', '.metadata.json'))).catch(() => {});
- await unlinkGuarded(join(PATHS.images, `${filename}.metadata.json`)).catch(() => {});
- // Drop the derived index row with the file (#2738). Without this the row
- // survives until the next boot reconcile, so anything counting the index
- // (the Character sheet's Auteur skill / Media Assets tile) reads high in
- // between. Non-fatal + dynamically imported: a broken index must never fail
- // the user's delete, and this keeps the pg stack out of this module's static
- // graph (the mirror of how the index dynamically imports the media stack).
- //
- // Gated on the PNG being CONFIRMED gone. The unlink above swallows its error,
- // so an EACCES/EBUSY/EIO failure leaves the image on disk and still listed by
- // listGallery() — unindexing it there would swap this bug for its mirror and
- // UNDERcount a live image. Failed-to-delete is not deleted.
- //
- // The probe is tri-state, NOT existsSync: that collapses "absent" and "I
- // couldn't tell" (EACCES on the dir, EIO) into the same `false`, which is the
- // absent-vs-failed sentinel trap — an unreadable gallery would read as "every
- // image is gone" and retire live rows. Only a definitive ENOENT retires the
- // row; present-or-unknown leaves it for the reconcile, which reads disk.
- const probeErr = await stat(join(PATHS.images, filename)).then(() => null, (err) => err);
- if (probeErr?.code === 'ENOENT') {
- await import('../mediaAssetIndex/index.js')
- .then((m) => m.unindexImage(filename))
- .catch((err) => console.error(`❌ Media index image delete hook: ${err.message}`));
- } else {
- console.error(`❌ Image file not confirmed gone (${probeErr?.code || 'still present'}), keeping its index row: ${filename}`);
- }
- console.log(`🗑️ Deleted image: ${filename}`);
+ return withBackupAssetPublication(() => sidecarEditQueue(filename, async () => {
+ await trashFiles([
+ join(PATHS.images, filename),
+ join(PATHS.images, filename.replace(/\.png$/i, '.metadata.json')),
+ join(PATHS.images, `${filename}.metadata.json`),
+ join(PATHS.imageThumbnails, filename.replace(/\.png$/i, '.webp')),
+ ]);
+ // trashFiles verifies removal before derived records can be retired.
+ await import('../mediaAssetIndex/index.js')
+ .then((m) => m.unindexImage(filename))
+ .catch((err) => console.error(`❌ Media index image delete hook: ${err.message}`));
+ console.log(`🗑️ Trashed image: ${filename}`);
return { ok: true };
- });
+ }));
}
// Sidecar edits are whole-file read→modify→replace cycles; atomicWrite stops a
@@ -1517,6 +1500,17 @@ function editImageSidecar(filename, mutate) {
const { path: sidecarPath, metadata } = await readImageSidecar(filename);
const result = mutate(metadata);
if (result === null) return null;
+ // A stale edit queued after deletion must not recreate its sidecar/index.
+ // Sidecar-only records remain editable while peer media bytes are pending.
+ const present = await Promise.all([
+ join(PATHS.images, filename),
+ join(PATHS.images, filename.replace(/\.png$/i, '.metadata.json')),
+ join(PATHS.images, `${filename}.metadata.json`),
+ ].map(path => stat(path).then(() => true, error => {
+ if (error.code === 'ENOENT') return false;
+ throw error;
+ })));
+ if (!present.some(Boolean)) throw new ServerError('Image not found', { status: 404, code: 'NOT_FOUND' });
await atomicWrite(sidecarPath, metadata);
await refreshImageIndex(filename);
return result;
diff --git a/server/services/mediaAssetIndex/gallery.js b/server/services/mediaAssetIndex/gallery.js
index c0f8d078c7..518ab38a0f 100644
--- a/server/services/mediaAssetIndex/gallery.js
+++ b/server/services/mediaAssetIndex/gallery.js
@@ -1,3 +1,4 @@
+import { withMediaFileSizes } from '../../lib/mediaFileInfo.js';
import { mapWithConcurrency } from '../../lib/mapWithConcurrency.js';
import { isTestRunner } from '../../lib/runtimeEnv.js';
import { listAssets, countAssets, galleryFacets, listMixedGalleryPage, collectionCovers, visibleImageCollections } from './db.js';
@@ -96,6 +97,7 @@ export async function listGalleryPage({
countAssets({ ...filters, compact }), summary ? countAssets({ ...filters, hidden: true, compact }) : undefined,
]);
}
+ items = await withMediaFileSizes(items, mixed ? undefined : kind);
return { items, total, limit, offset, ...(summary ? { hiddenTotal, ...(counts ? { counts } : {}) } : {}) };
}
@@ -187,7 +189,7 @@ export async function listImageVariants(filename, diskReader) {
if (!self) return [];
const root = rootOf(self);
const original = images.find(image => image?.filename === root && isRoot(image));
- return [...(original ? [original] : []), ...images.filter(image => image?.cleanedFrom === root)];
+ return withMediaFileSizes([...(original ? [original] : []), ...images.filter(image => image?.cleanedFrom === root)], 'image');
}
const [self] = await listAssets({ kind: 'image', filename, limit: 1 });
@@ -199,5 +201,5 @@ export async function listImageVariants(filename, diskReader) {
root === filename ? [self] : listAssets({ kind: 'image', filename: root, limit: 1 }),
listAssets({ kind: 'image', cleanedFrom: root }),
]);
- return [...(isRoot(original) ? [original] : []), ...copies];
+ return withMediaFileSizes([...(isRoot(original) ? [original] : []), ...copies], 'image');
}
diff --git a/server/services/mediaAssetIndex/galleryFileSizes.test.js b/server/services/mediaAssetIndex/galleryFileSizes.test.js
new file mode 100644
index 0000000000..79057970ef
--- /dev/null
+++ b/server/services/mediaAssetIndex/galleryFileSizes.test.js
@@ -0,0 +1,53 @@
+/** Old records acquire current sizes through the paged gallery boundary. */
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import { mkdtemp, mkdir, writeFile, rm } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { listGalleryPage } from './gallery.js';
+
+const state = vi.hoisted(() => ({ root: null, stat: vi.fn() }));
+vi.mock('node:fs/promises', async original => {
+ const actual = await original();
+ state.stat.mockImplementation(actual.stat);
+ return { ...actual, stat: state.stat };
+});
+vi.mock('../../lib/paths.js', async original => {
+ const actual = await original();
+ return { ...actual, PATHS: {
+ ...actual.PATHS,
+ get images() { return join(state.root, 'images'); },
+ get videos() { return join(state.root, 'videos'); },
+} };
+});
+beforeEach(async () => {
+ state.root = await mkdtemp(join(tmpdir(), 'portos-gallery-sizes-'));
+ await Promise.all(['images', 'videos'].map(kind => mkdir(join(state.root, kind))));
+ state.stat.mockClear();
+});
+afterEach(async () => { await rm(state.root, { recursive: true, force: true }); });
+
+it('measures only the selected mixed compact page, including legacy video records', async () => {
+ await writeFile(join(state.root, 'images', 'old.png'), 'pixels');
+ await writeFile(join(state.root, 'videos', 'old.mp4'), Buffer.alloc(1536));
+ const image = { filename: 'old.png', createdAt: '2026-01-01', fileSizeBytes: 999 };
+ const video = { id: 'old', filename: 'old.mp4', createdAt: '2026-01-02', fps: 24 };
+ const options = { media: true, kind: 'all', compact: true, limit: 1, videoSnapshot: [video] };
+ const first = await listGalleryPage(options, async () => [image]);
+ expect(first.items).toEqual([{ kind: 'video', data: expect.objectContaining({ fileSizeBytes: 1536, fps: 24, compact: true }) }]);
+ expect(state.stat.mock.calls.map(([path]) => path)).toEqual([join(state.root, 'videos', 'old.mp4')]);
+ const second = await listGalleryPage({ ...options, offset: 1 }, async () => [image]);
+ expect(second.items[0].data.fileSizeBytes).toBe(6);
+});
+
+it('distinguishes a measured empty file from missing, unreadable and unsafe files', async () => {
+ await writeFile(join(state.root, 'images', 'empty.png'), '');
+ const files = ['empty.png', 'missing.png', 'denied.png', '../outside.png'].map(filename => ({ filename, fileSizeBytes: 999 }));
+ state.stat.mockImplementation(async path => {
+ if (path.endsWith('denied.png')) throw Object.assign(new Error('permission denied'), { code: 'EACCES' });
+ return (await vi.importActual('node:fs/promises')).stat(path);
+ });
+ const page = await listGalleryPage({}, async () => files);
+ expect(page.items.find(item => item.filename === 'empty.png').fileSizeBytes).toBe(0);
+ for (const item of page.items.filter(item => item.filename !== 'empty.png')) expect(item).not.toHaveProperty('fileSizeBytes');
+ expect(state.stat.mock.calls).toHaveLength(3);
+});
diff --git a/server/services/mediaAssetIndex/logic.js b/server/services/mediaAssetIndex/logic.js
index 0dcb9a5636..78fefe5419 100644
--- a/server/services/mediaAssetIndex/logic.js
+++ b/server/services/mediaAssetIndex/logic.js
@@ -75,7 +75,7 @@ export function videoToRow(entry, { now } = {}) {
// negative prompts, provider payloads — stays on the record and is read on
// demand (`/gallery/lookup`, `/video-gen/history/:id`).
const COMPACT_FIELDS = ['id', 'filename', 'path', 'thumbnail', 'createdAt', 'hidden', 'width', 'height',
- 'appId', 'model', 'modelId', 'mode', 'seed', 'steps', 'numFrames', 'fps', 'renderMs', 'loraFilenames',
+ 'appId', 'model', 'modelId', 'mode', 'seed', 'steps', 'numFrames', 'fps', 'fileSizeBytes', 'renderMs', 'loraFilenames',
'lora_filenames', 'loraPaths', 'lora_paths', 'stitchedFrom', 'upscaledFrom', 'extractedFromVideoId',
'cleanedFrom', 'autoCleaned', 'regenerated', 'watermarkRemoved'];
export const COMPACT_PROMPT_CHARS = 240;
diff --git a/server/services/mediaAssetMutationAdmission.test.js b/server/services/mediaAssetMutationAdmission.test.js
index ad91783e48..9b6579195a 100644
--- a/server/services/mediaAssetMutationAdmission.test.js
+++ b/server/services/mediaAssetMutationAdmission.test.js
@@ -1,8 +1,31 @@
+// Keep recovered bytes in the fixture; never touch the host's Trash.
+const recycled = new Map();
+vi.mock('../lib/nativeTrash.js', () => ({ moveToNativeTrash: async paths => {
+ const { unlink } = await import('node:fs/promises');
+ for (const path of paths) {
+ recycled.set(basename(path), await readFile(path));
+ await unlink(path);
+ }
+} }));
+let publicationStarted = null;
+let trashCalls = 0;
+vi.mock('../lib/backupSnapshotBoundary.js', async original => {
+ const actual = await original();
+ return { ...actual, withBackupAssetPublication: work => actual.withBackupAssetPublication(() => {
+ const result = work();
+ publicationStarted?.();
+ return result;
+ }) };
+});
+vi.mock('../lib/trashFiles.js', async original => {
+ const actual = await original();
+ return { ...actual, trashFiles: paths => { trashCalls++; return actual.trashFiles(paths); } };
+});
/** Real gallery/history workflows and files, with the derived PG index held at
* its commit seam. A cut must never enter after bytes change but before rows do. */
import { afterAll, beforeEach, expect, it, vi } from 'vitest';
import { mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises';
-import { join } from 'node:path';
+import { join, basename } from 'node:path';
import sharp from 'sharp';
import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../lib/mockPathsDataRoot.js';
@@ -42,6 +65,9 @@ const deferred = () => {
afterAll(cleanupTempDataRoots);
beforeEach(async () => {
rows.clear();
+ recycled.clear();
+ publicationStarted = null;
+ trashCalls = 0;
beforeIndexWrite = async () => {};
await rm(PATHS.data, { recursive: true, force: true });
await Promise.all([PATHS.images, PATHS.videos, PATHS.imageThumbnails, PATHS.videoThumbnails]
@@ -183,3 +209,34 @@ it('drains a queued sidecar edit through its index commit before taking the cut'
expect(rows.get('fixture.png')).toMatchObject({ prompt: 'after', hidden: true });
expect(await readMetadata()).toEqual({ prompt: 'after', hidden: true });
});
+
+it('recycles the latest image edit and refuses a stale edit queued behind deletion', async () => {
+ const editReached = deferred();
+ const commitEdit = deferred();
+ beforeIndexWrite = async () => { editReached.resolve(); await commitEdit.promise; };
+ const prompt = updateImagePrompt('fixture.png', 'latest prompt');
+ await editReached.promise;
+ // This fixture boundary acknowledges the deletion callback has returned
+ // its queued work, so absence of trashCalls proves serialization without a sleep.
+ const deletionStarted = deferred();
+ publicationStarted = () => deletionStarted.resolve();
+ const deletion = deleteImage('fixture.png');
+ let stale;
+ try {
+ await deletionStarted.promise;
+ expect(trashCalls).toBe(0);
+ publicationStarted = null;
+ stale = setImageHidden('fixture.png', true);
+ const rejected = expect(stale).rejects.toMatchObject({ code: 'NOT_FOUND' });
+ commitEdit.resolve();
+ await Promise.all([prompt, deletion, rejected]);
+ expect(JSON.parse(recycled.get('fixture.metadata.json').toString())).toEqual({ prompt: 'latest prompt', hidden: false });
+ expect(recycled.get('fixture.png')).toEqual(png);
+ expect(rows.has('fixture.png')).toBe(false);
+ await expect(readFile(metadataPath)).rejects.toMatchObject({ code: 'ENOENT' });
+ } finally {
+ publicationStarted = null;
+ commitEdit.resolve();
+ await Promise.allSettled([prompt, deletion, stale]);
+ }
+});
diff --git a/server/services/universeAssetBackupAdmission.test.js b/server/services/universeAssetBackupAdmission.test.js
index 38c94828e7..6824b19a4e 100644
--- a/server/services/universeAssetBackupAdmission.test.js
+++ b/server/services/universeAssetBackupAdmission.test.js
@@ -1,3 +1,8 @@
+// Keep the filesystem half real without touching the host's Trash.
+vi.mock('../lib/nativeTrash.js', () => ({ moveToNativeTrash: async paths => {
+ const { unlink } = await import('node:fs/promises');
+ for (const path of paths) await unlink(path);
+} }));
/** Universe asset workflows over real files, with the universe row write held
* at its commit seam. A backup cut must never land between a sheet copy or file
* removal and the universe row that names (or stops naming) those bytes. */
diff --git a/server/services/videoGen/deleteHistoryItem.test.js b/server/services/videoGen/deleteHistoryItem.test.js
index 36857729f8..894c141aa3 100644
--- a/server/services/videoGen/deleteHistoryItem.test.js
+++ b/server/services/videoGen/deleteHistoryItem.test.js
@@ -61,6 +61,8 @@ vi.mock('../hfToken.js', () => ({
getHfToken: vi.fn(async () => null),
}));
+const trashFiles = vi.fn(async () => {});
+vi.mock('../../lib/trashFiles.js', () => ({ trashFiles }));
const unlink = vi.fn(async () => {});
vi.mock('fs/promises', () => ({ unlink, writeFile: vi.fn(async () => {}), copyFile: vi.fn(async () => {}) }));
vi.mock('fs', () => ({ existsSync: vi.fn(() => true), statSync: vi.fn(() => ({ size: 1000 })) }));
@@ -69,7 +71,7 @@ vi.mock('fs', () => ({ existsSync: vi.fn(() => true), statSync: vi.fn(() => ({ s
// mutator to the live list so the test can assert the entry really left.
let history = [];
const loadHistory = vi.fn(async () => history.slice());
-const mutateVideoHistory = vi.fn(async (fn) => { history = fn(history.slice()); return history; });
+const mutateVideoHistory = vi.fn(async (fn) => { history = await fn(history.slice()); return history; });
vi.mock('./history.js', () => ({ loadHistory, mutateVideoHistory, saveHistory: vi.fn(async () => {}) }));
const unindexVideo = vi.fn(async () => {});
@@ -94,12 +96,15 @@ describe('deleteHistoryItem → media asset index delete hook', () => {
expect(unindexVideo).not.toHaveBeenCalledWith('job-1.mp4');
});
- it('removes the Extend audio master kept beside the clip', async () => {
+ it('recycles the clip and Extend audio master with a recovery metadata snapshot', async () => {
await deleteHistoryItem('job-1');
- const unlinked = unlink.mock.calls.map(([path]) => path);
+ const { atomicWrite } = await import('../../lib/fileUtils.js');
+ expect(atomicWrite).toHaveBeenCalledWith(join(MOCK_PATHS.videos, 'job-1.mp4.metadata.json'), expect.objectContaining({ id: 'job-1', filename: 'job-1.mp4' }));
+ const unlinked = trashFiles.mock.calls.flatMap(([paths]) => paths);
expect(unlinked).toContain(join(MOCK_PATHS.videos, 'job-1.mp4'));
expect(unlinked).toContain(join(MOCK_PATHS.videos, 'job-1.master.flac'));
+ expect(unlinked).toContain(join(MOCK_PATHS.videos, 'job-1.mp4.metadata.json'));
});
it('is non-fatal: a failing index removal still removes the entry and returns ok', async () => {
@@ -117,3 +122,10 @@ describe('deleteHistoryItem → media asset index delete hook', () => {
expect(unindexVideo).not.toHaveBeenCalled();
});
});
+
+it('preserves video history and its index when recycling fails', async () => {
+ trashFiles.mockRejectedValueOnce(new Error('recycle unavailable'));
+ await expect(deleteHistoryItem('job-1')).rejects.toThrow('recycle unavailable');
+ expect(history).toHaveLength(1);
+ expect(unindexVideo).not.toHaveBeenCalled();
+});
diff --git a/server/services/videoGen/historyOps.js b/server/services/videoGen/historyOps.js
index a00bb9a7c8..1bf32578c0 100644
--- a/server/services/videoGen/historyOps.js
+++ b/server/services/videoGen/historyOps.js
@@ -1,10 +1,11 @@
/** User-facing video-history mutations. */
-import { PATHS, unlinkGuarded } from '../../lib/fileUtils.js';
+import { trashFiles } from '../../lib/trashFiles.js';
+import { PATHS, atomicWrite } from '../../lib/fileUtils.js';
import { ServerError } from '../../lib/errorHandler.js';
import { withBackupAssetPublication } from '../../lib/backupSnapshotBoundary.js';
import { safeUnder } from '../../lib/ffmpeg.js';
-import { loadHistory, mutateVideoHistory } from './history.js';
+import { mutateVideoHistory } from './history.js';
import { extendMasterPath } from './extendMaster.js';
export async function updateHistoryItemPrompt(id, prompt) {
@@ -45,30 +46,25 @@ export async function deleteHistoryItem(id, { forgetInMusicVideos = true } = {})
// One lease covers the history read, file removals, history rewrite, and
// derived row removal; per-file admission would leave gaps between stores.
return withBackupAssetPublication(async () => {
- const history = await loadHistory();
- const item = history.find((h) => h.id === id);
- if (!item) throw new ServerError('Not found', { status: 404, code: 'NOT_FOUND' });
- // Same path-traversal guard as extractLastFrame — unlink only if the
- // filename resolves to inside the expected dir.
- const videoFile = safeUnder(PATHS.videos, item.filename);
- if (videoFile) await unlinkGuarded(videoFile).catch(() => {});
- // The lossless audio master an Extend output keeps beside it (extendSplice.js).
- const masterFile = videoFile && extendMasterPath(videoFile);
- if (masterFile) await unlinkGuarded(masterFile).catch(() => {});
- if (item.thumbnail) {
- const thumbFile = safeUnder(PATHS.videoThumbnails, item.thumbnail);
- if (thumbFile) await unlinkGuarded(thumbFile).catch(() => {});
- }
- // Delete evaluation frame thumbnails written by sampleEvaluationFrames:
- // `${jobId}-f1.jpg` … `${jobId}-f9.jpg` (max count in sampleEvaluationFrames is 5,
- // but 9 is a safe upper bound to catch any future increase).
- for (let i = 1; i <= 9; i++) {
- const frameFile = safeUnder(PATHS.videoThumbnails, `${id}-f${i}.jpg`);
- if (frameFile) await unlinkGuarded(frameFile).catch(() => {});
- }
- // Serialized removal through the shared tail (re-filters the freshest list),
- // so a concurrent download/render append isn't dropped by this save.
- await mutateVideoHistory((h) => h.filter((x) => x.id !== id));
+ let item;
+ // Hold the history writer across its recovery snapshot and the file move,
+ // so overlapping prompt edits/deletes cannot retire a different revision.
+ await mutateVideoHistory(async history => {
+ item = history.find((entry) => entry.id === id);
+ if (!item) throw new ServerError('Not found', { status: 404, code: 'NOT_FOUND' });
+ const videoFile = safeUnder(PATHS.videos, item.filename);
+ if (!videoFile) throw new ServerError('Invalid video filename', { status: 400, code: 'INVALID_VIDEO_PATH' });
+ // The shared history file stays in place; recycle a per-video copy of
+ // this record alongside its bytes so prompts/settings remain recoverable.
+ const metadataFile = `${videoFile}.metadata.json`;
+ await atomicWrite(metadataFile, item);
+ const files = [videoFile, metadataFile, extendMasterPath(videoFile)];
+ if (item.thumbnail) files.push(safeUnder(PATHS.videoThumbnails, item.thumbnail));
+ // Evaluation frames are derived; include all supported frame slots.
+ for (let i = 1; i <= 9; i++) files.push(safeUnder(PATHS.videoThumbnails, `${id}-f${i}.jpg`));
+ await trashFiles(files);
+ return history.filter(entry => entry.id !== id);
+ });
// Drop the derived index row with the entry (#2738) — keyed by job id, the
// ref the index wrote it under. Non-fatal + dynamically imported; see the
// matching hook in imageGen/local.js#deleteImage for the rationale.
@@ -78,7 +74,7 @@ export async function deleteHistoryItem(id, { forgetInMusicVideos = true } = {})
// Music videos forget it too (their unused takes, marks and collection rows);
// a batch delete from a video's asset manager forgets its whole batch at once.
if (forgetInMusicVideos) await import('../musicVideo/mediaPool.js').then((m) => m.forgetDeletedMusicVideoAssets([`video:${id}`]));
- console.log(`🗑️ Deleted video: ${item.filename}`);
+ console.log(`🗑️ Trashed video: ${item.filename}`);
return { ok: true };
});
}