Clear image subtitle caches when video stream sessions end
Image subtitle frame and event caches were accumulating indefinitely, even after a video stream session ended. After watching ~10 videos with image-based subtitles, memory fragmentation would cause rendering delays and missing frames. Now when a video stream session is destroyed (all leases released), the associated image subtitle caches are immediately cleared via clearCachesForFile(). This follows the same pattern as video chunk cleanup and prevents unbounded growth.
@@ -12,6 +12,7 @@
12
12
## server/image-subtitles.js
13
13
- parseRenderOptions(options) - Normalises subtitle-frame request options and validates filePath/streamIndex/time/canvas dimensions; stream index `0` is valid and must not be treated as missing.
14
14
- renderImageSubtitleFrame({ filePath, streamIndex, timeSeconds, canvasWidth, canvasHeight }) - Extracts bitmap subtitle streams to cached `.sup`, parses PGS display sets, and returns cached/composited PNG subtitle frames for a requested timestamp; returns null when no subtitle is active.
15
- clearCachesForFile(filePath) - Removes all event and frame cache entries for a given file path; called when video stream sessions end to prevent memory accumulation.
15
16
16
17
## server/thumbnail-cache.js
17
18
- syncThumbnailCacheOnce() - Mirrors configured roots and userPath into public/thumbs and generates 99x99-max WebP thumbnails for image files, video files (ffprobe/ffmpeg frame at ~10%), and 3D model files (STL/OBJ, isometric SVG projection via Sharp); removes stale thumbnails and updates manifest hashes.
@@ -104,7 +105,7 @@
104
105
## server/video-stream.js
105
106
- createVideoStreamSession(sourcePath) - Probes input metadata and reuses a compatible active transcode session per source file when possible; returns a per-viewer lease id as sessionId plus duration, videoWidth, videoHeight, subtitleTracks, imageSubtitleTracks, and subtitleSummary data.
106
107
- sendVideoStreamAsset(sessionId, assetPath, req, res) - Resolves viewer leases to a shared stream session, serves HLS assets, tracks lease activity, and prunes segments using the slowest active viewer position.
107
- releaseVideoStreamSession(sessionId) - Releases one viewer lease; only destroys the underlying transcode session when no active leases remain.
108
- releaseVideoStreamSession(sessionId) - Releases one viewer lease; only destroys the underlying transcode session when no active leases remain; cleanup also clears image subtitle frame/event caches to prevent memory accumulation.
108
109
- STREAM_ROOT_DIR - Temporary root directory for active ffmpeg-backed stream sessions.
109
110
- STREAM_SESSION_TTL_MS - Idle lifetime for a stream session before cleanup.
110
111
- STREAM_IDLE_STOP_MS - Maximum client inactivity window before an active stream session is terminated (5 minutes).
@@ -126,7 +127,6 @@
126
127
## public/index.html
127
128
- Auth form - Login/setup form uses username plus mode-specific password autocomplete tokens so browser password managers behave correctly.
128
129
- Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
129
- Admin topbar button - Includes the `#admin-update-badge` element that displays pending update commit count for admins.
130
130
- Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
131
131
132
132
## public/app.js
@@ -150,8 +150,6 @@
150
150
- showFileConflictChoice(filename, renameTo, mode) - Dialog for single upload/move conflicts; returns overwrite/rename/cancel.
151
151
- parseHumanSize(input) - Parses human-readable sizes like `25 MB`/`1gb` into bytes for admin user-folder limits.
152
152
- updateAdminSizeFeedback(rawValue) - Validates size input and updates admin hint text/classes with parsed byte preview.
153
- setAdminUpdateBadge(count) - Shows/hides the admin topbar update badge and clamps display to `99+` for large update counts.
154
- pulseAdminUpdateButton() - Scrolls the admin modal to the shutdown/update CTA and applies a short pulse highlight animation.
155
153
- relativePathFromRoot(targetPath, rootPath) - Produces a root-relative path string for sidebar folder context display.
156
154
- displayPathWithRootLabel(targetPath, rootPath, rootLabel) - Produces Linux-style root-relative display paths like `/Downloads/A/B` for folder context UI.
157
155
- openShareModal(item) - Opens the Delen (share) popup, calls POST /api/share/create, shows the 24-hour URL with a copy button and OK to dismiss.
@@ -179,7 +177,6 @@
179
177
- buildModelObjectFromBlob(blob, type, modules) - Parses STL/OBJ blobs and produces a geometry-only model using the standard blue material.
180
178
- renderModelPreview(item, blob, targetEl) - Renders interactive STL/OBJ previews (drag rotate + scroll zoom) with WebGL fallback messaging when unavailable.
181
179
- closePreview(opts) - Closes expanded previews; video previews ignore backdrop close and require explicit close action.
182
- refreshAdminUpdateStatus(opts) - Fetches `/api/admin/update-status`, updates CTA label, updates topbar badge, and optionally triggers update-button pulse/scroll in the admin modal.
183
180
184
181
## tests/thumbnail-cache.test.js
185
182
- thumbnail cache worker / creates cached thumbnail with dimensions smaller than 100px - Verifies cached image generation and manifest write.
@@ -255,12 +252,6 @@
255
252
## public/style.css
256
253
- #sidebar-duplicates + related classes - Sidebar duplicate-file list styling with truncation and hover feedback.
257
254
- .admin-size-feedback(.ok/.err) - Validation feedback styling for admin user-folder size-limit input.
258
- .topbar-badge - Red count badge attached to the admin topbar button for available updates.
259
- .admin-update-highlight / @keyframes admin-update-pulse - Temporary pulse animation class used to highlight the Restart & Update CTA.
260
261
## installsystemdservice.sh
262
- maybe_install_system_dependencies() - Detects missing runtime tools (`node`, `npm`, `git`, `ffmpeg`, `ffprobe`) from a single command list, asks whether to install dependencies, then tries supported package managers (`apt-get`, `apt`, `dnf`, `yum`, `pacman`, `zypper`, `apk`) with warning logs for unavailable or failing managers.
263
- install_with_package_manager(pm) - Runs package-manager-specific install commands using the central `REQUIRED_PACKAGES` list so dependency updates only need one edit.
264
255
265
256
## tests/auth.routes.test.js
266
257
- session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
@@ -268,8 +259,6 @@
268
259
269
260
## tests/page.load.test.js
270
261
- bootClient() - Boots the app in jsdom and waits until app shell is visible or timeout before assertions.
271
- admin topbar shows update badge after login when updates are available - Verifies admins see the pending-update count badge immediately after boot/login restore.
272
- opening admin panel with updates scrolls to and highlights the update button - Verifies modal open triggers scroll-to-CTA and pulse highlight when updates exist.
273
262
- waitFor(dom, predicate, timeoutMs) - Poll helper used by interaction tests to wait for rendered tiles.
274
263
- login overlay uses username and current-password autocomplete tokens - Verifies normal sign-in mode exposes browser-friendly login autocomplete attributes.
275
264
- first-run setup uses new-password autocomplete token - Verifies setup mode switches the password field to the browser-friendly new-password token.
@@ -12,6 +12,7 @@12
## server/image-subtitles.js
12
## server/image-subtitles.js
13
- parseRenderOptions(options) - Normalises subtitle-frame request options and validates filePath/streamIndex/time/canvas dimensions; stream index `0` is valid and must not be treated as missing.
13
- parseRenderOptions(options) - Normalises subtitle-frame request options and validates filePath/streamIndex/time/canvas dimensions; stream index `0` is valid and must not be treated as missing.
14
- renderImageSubtitleFrame({ filePath, streamIndex, timeSeconds, canvasWidth, canvasHeight }) - Extracts bitmap subtitle streams to cached `.sup`, parses PGS display sets, and returns cached/composited PNG subtitle frames for a requested timestamp; returns null when no subtitle is active.
14
- renderImageSubtitleFrame({ filePath, streamIndex, timeSeconds, canvasWidth, canvasHeight }) - Extracts bitmap subtitle streams to cached `.sup`, parses PGS display sets, and returns cached/composited PNG subtitle frames for a requested timestamp; returns null when no subtitle is active.
15
- clearCachesForFile(filePath) - Removes all event and frame cache entries for a given file path; called when video stream sessions end to prevent memory accumulation.
15
16
16
## server/thumbnail-cache.js
17
## server/thumbnail-cache.js
17
- syncThumbnailCacheOnce() - Mirrors configured roots and userPath into public/thumbs and generates 99x99-max WebP thumbnails for image files, video files (ffprobe/ffmpeg frame at ~10%), and 3D model files (STL/OBJ, isometric SVG projection via Sharp); removes stale thumbnails and updates manifest hashes.
18
- syncThumbnailCacheOnce() - Mirrors configured roots and userPath into public/thumbs and generates 99x99-max WebP thumbnails for image files, video files (ffprobe/ffmpeg frame at ~10%), and 3D model files (STL/OBJ, isometric SVG projection via Sharp); removes stale thumbnails and updates manifest hashes.
@@ -104,7 +105,7 @@104
## server/video-stream.js
105
## server/video-stream.js
105
- createVideoStreamSession(sourcePath) - Probes input metadata and reuses a compatible active transcode session per source file when possible; returns a per-viewer lease id as sessionId plus duration, videoWidth, videoHeight, subtitleTracks, imageSubtitleTracks, and subtitleSummary data.
106
- createVideoStreamSession(sourcePath) - Probes input metadata and reuses a compatible active transcode session per source file when possible; returns a per-viewer lease id as sessionId plus duration, videoWidth, videoHeight, subtitleTracks, imageSubtitleTracks, and subtitleSummary data.
106
- sendVideoStreamAsset(sessionId, assetPath, req, res) - Resolves viewer leases to a shared stream session, serves HLS assets, tracks lease activity, and prunes segments using the slowest active viewer position.
107
- sendVideoStreamAsset(sessionId, assetPath, req, res) - Resolves viewer leases to a shared stream session, serves HLS assets, tracks lease activity, and prunes segments using the slowest active viewer position.
107
- releaseVideoStreamSession(sessionId) - Releases one viewer lease; only destroys the underlying transcode session when no active leases remain.
108
- releaseVideoStreamSession(sessionId) - Releases one viewer lease; only destroys the underlying transcode session when no active leases remain; cleanup also clears image subtitle frame/event caches to prevent memory accumulation.
108
- STREAM_ROOT_DIR - Temporary root directory for active ffmpeg-backed stream sessions.
109
- STREAM_ROOT_DIR - Temporary root directory for active ffmpeg-backed stream sessions.
109
- STREAM_SESSION_TTL_MS - Idle lifetime for a stream session before cleanup.
110
- STREAM_SESSION_TTL_MS - Idle lifetime for a stream session before cleanup.
110
- STREAM_IDLE_STOP_MS - Maximum client inactivity window before an active stream session is terminated (5 minutes).
111
- STREAM_IDLE_STOP_MS - Maximum client inactivity window before an active stream session is terminated (5 minutes).
@@ -126,7 +127,6 @@126
## public/index.html
127
## public/index.html
127
- Auth form - Login/setup form uses username plus mode-specific password autocomplete tokens so browser password managers behave correctly.
128
- Auth form - Login/setup form uses username plus mode-specific password autocomplete tokens so browser password managers behave correctly.
128
- Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
129
- Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
129
- Admin topbar button - Includes the `#admin-update-badge` element that displays pending update commit count for admins.
130
- Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
130
- Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
131
131
132
## public/app.js
132
## public/app.js
@@ -150,8 +150,6 @@150
- showFileConflictChoice(filename, renameTo, mode) - Dialog for single upload/move conflicts; returns overwrite/rename/cancel.
150
- showFileConflictChoice(filename, renameTo, mode) - Dialog for single upload/move conflicts; returns overwrite/rename/cancel.
151
- parseHumanSize(input) - Parses human-readable sizes like `25 MB`/`1gb` into bytes for admin user-folder limits.
151
- parseHumanSize(input) - Parses human-readable sizes like `25 MB`/`1gb` into bytes for admin user-folder limits.
152
- updateAdminSizeFeedback(rawValue) - Validates size input and updates admin hint text/classes with parsed byte preview.
152
- updateAdminSizeFeedback(rawValue) - Validates size input and updates admin hint text/classes with parsed byte preview.
153
- setAdminUpdateBadge(count) - Shows/hides the admin topbar update badge and clamps display to `99+` for large update counts.
154
- pulseAdminUpdateButton() - Scrolls the admin modal to the shutdown/update CTA and applies a short pulse highlight animation.
155
- relativePathFromRoot(targetPath, rootPath) - Produces a root-relative path string for sidebar folder context display.
153
- relativePathFromRoot(targetPath, rootPath) - Produces a root-relative path string for sidebar folder context display.
156
- displayPathWithRootLabel(targetPath, rootPath, rootLabel) - Produces Linux-style root-relative display paths like `/Downloads/A/B` for folder context UI.
154
- displayPathWithRootLabel(targetPath, rootPath, rootLabel) - Produces Linux-style root-relative display paths like `/Downloads/A/B` for folder context UI.
157
- openShareModal(item) - Opens the Delen (share) popup, calls POST /api/share/create, shows the 24-hour URL with a copy button and OK to dismiss.
155
- openShareModal(item) - Opens the Delen (share) popup, calls POST /api/share/create, shows the 24-hour URL with a copy button and OK to dismiss.
@@ -179,7 +177,6 @@179
- buildModelObjectFromBlob(blob, type, modules) - Parses STL/OBJ blobs and produces a geometry-only model using the standard blue material.
177
- buildModelObjectFromBlob(blob, type, modules) - Parses STL/OBJ blobs and produces a geometry-only model using the standard blue material.
180
- renderModelPreview(item, blob, targetEl) - Renders interactive STL/OBJ previews (drag rotate + scroll zoom) with WebGL fallback messaging when unavailable.
178
- renderModelPreview(item, blob, targetEl) - Renders interactive STL/OBJ previews (drag rotate + scroll zoom) with WebGL fallback messaging when unavailable.
181
- closePreview(opts) - Closes expanded previews; video previews ignore backdrop close and require explicit close action.
179
- closePreview(opts) - Closes expanded previews; video previews ignore backdrop close and require explicit close action.
182
- refreshAdminUpdateStatus(opts) - Fetches `/api/admin/update-status`, updates CTA label, updates topbar badge, and optionally triggers update-button pulse/scroll in the admin modal.
183
180
184
## tests/thumbnail-cache.test.js
181
## tests/thumbnail-cache.test.js
185
- thumbnail cache worker / creates cached thumbnail with dimensions smaller than 100px - Verifies cached image generation and manifest write.
182
- thumbnail cache worker / creates cached thumbnail with dimensions smaller than 100px - Verifies cached image generation and manifest write.
@@ -255,12 +252,6 @@255
## public/style.css
252
## public/style.css
256
- #sidebar-duplicates + related classes - Sidebar duplicate-file list styling with truncation and hover feedback.
253
- #sidebar-duplicates + related classes - Sidebar duplicate-file list styling with truncation and hover feedback.
257
- .admin-size-feedback(.ok/.err) - Validation feedback styling for admin user-folder size-limit input.
254
- .admin-size-feedback(.ok/.err) - Validation feedback styling for admin user-folder size-limit input.
258
- .topbar-badge - Red count badge attached to the admin topbar button for available updates.
259
- .admin-update-highlight / @keyframes admin-update-pulse - Temporary pulse animation class used to highlight the Restart & Update CTA.
260
261
## installsystemdservice.sh
262
- maybe_install_system_dependencies() - Detects missing runtime tools (`node`, `npm`, `git`, `ffmpeg`, `ffprobe`) from a single command list, asks whether to install dependencies, then tries supported package managers (`apt-get`, `apt`, `dnf`, `yum`, `pacman`, `zypper`, `apk`) with warning logs for unavailable or failing managers.
263
- install_with_package_manager(pm) - Runs package-manager-specific install commands using the central `REQUIRED_PACKAGES` list so dependency updates only need one edit.
264
255
265
## tests/auth.routes.test.js
256
## tests/auth.routes.test.js
266
- session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
257
- session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
@@ -268,8 +259,6 @@268
259
269
## tests/page.load.test.js
260
## tests/page.load.test.js
270
- bootClient() - Boots the app in jsdom and waits until app shell is visible or timeout before assertions.
261
- bootClient() - Boots the app in jsdom and waits until app shell is visible or timeout before assertions.
271
- admin topbar shows update badge after login when updates are available - Verifies admins see the pending-update count badge immediately after boot/login restore.
272
- opening admin panel with updates scrolls to and highlights the update button - Verifies modal open triggers scroll-to-CTA and pulse highlight when updates exist.
273
- waitFor(dom, predicate, timeoutMs) - Poll helper used by interaction tests to wait for rendered tiles.
262
- waitFor(dom, predicate, timeoutMs) - Poll helper used by interaction tests to wait for rendered tiles.
274
- login overlay uses username and current-password autocomplete tokens - Verifies normal sign-in mode exposes browser-friendly login autocomplete attributes.
263
- login overlay uses username and current-password autocomplete tokens - Verifies normal sign-in mode exposes browser-friendly login autocomplete attributes.
275
- first-run setup uses new-password autocomplete token - Verifies setup mode switches the password field to the browser-friendly new-password token.
264
- first-run setup uses new-password autocomplete token - Verifies setup mode switches the password field to the browser-friendly new-password token.
@@ -1536,14 +1536,6 @@ function showApp ()
1536
1536
openFolderSidebar();
1537
1537
}
1538
1538
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);
1539
if (STATE.isAdmin)
1540
{
1541
void refreshAdminUpdateStatus();
1542
}
1543
else
1544
{
1545
setAdminUpdateBadge(0);
1546
}
1547
1539
startAutoRefresh();
1548
1540
}
1549
1541
@@ -1667,8 +1659,6 @@ async function performLogout ()
1667
1659
STATE.restoreDir = null;
1668
1660
STATE.restoreRootPath = null;
1669
1661
STATE.lastOperationAt = null;
1670
_adminUpdateStatus = null;
1671
setAdminUpdateBadge(0);
1672
1662
clearSessionState();
1673
1663
closePreview({ force: true });
1674
1664
closeSidebar();
@@ -4583,54 +4573,12 @@ async function deleteItem (item)
4583
4573
4584
4574
let _adminUpdateStatus = null;
4585
4575
4586
function setAdminUpdateBadge (count)
4587
{
4588
const badge = document.getElementById('admin-update-badge');
4589
const adminBtn = document.getElementById('btn-admin');
4590
if (!badge || !adminBtn) return;
4591
4592
if (!STATE.isAdmin || !Number.isFinite(count) || count <= 0)
4593
{
4594
badge.classList.add('hidden');
4595
badge.textContent = '';
4596
adminBtn.removeAttribute('data-update-count');
4597
return;
4598
}
4599
4600
const whole = Math.floor(count);
4601
const capped = Math.min(whole, 99);
4602
badge.textContent = capped >= 99 ? '99+' : String(capped);
4603
badge.classList.remove('hidden');
4604
adminBtn.dataset.updateCount = String(whole);
4605
}
4606
4607
function pulseAdminUpdateButton ()
4608
{
4609
const btn = document.getElementById('admin-shutdown-btn');
4610
if (!btn) return;
4611
4612
if (typeof btn.scrollIntoView === 'function')
4613
{
4614
btn.scrollIntoView({ behavior: 'smooth', block: 'center' });
4615
}
4616
4617
btn.classList.remove('admin-update-highlight');
4618
// Force reflow so repeated openings can replay the pulse animation.
4619
void btn.offsetWidth;
4620
btn.classList.add('admin-update-highlight');
4621
4622
setTimeout(() =>
4623
{
4624
btn.classList.remove('admin-update-highlight');
4625
}, 1800);
4626
}
4627
4628
4576
async function openAdminModal ()
4629
4577
{
4630
4578
document.getElementById('admin-modal').classList.remove('hidden');
4631
4579
await refreshAdminConfig();
4632
4580
await refreshAdminUsers();
4633
await refreshAdminUpdateStatus({ pulseIfUpdateAvailable: true });
4581
void refreshAdminUpdateStatus();
4634
4582
}
4635
4583
4636
4584
async function refreshAdminConfig ()
@@ -4700,13 +4648,11 @@ async function refreshAdminUsers ()
4700
4648
}
4701
4649
}
4702
4650
4703
async function refreshAdminUpdateStatus (opts = {})
4651
async function refreshAdminUpdateStatus ()
4704
4652
{
4705
const pulseIfUpdateAvailable = !!opts.pulseIfUpdateAvailable;
4706
4653
const btn = document.getElementById('admin-shutdown-btn');
4707
4654
_adminUpdateStatus = null;
4708
4655
btn.textContent = 'Shut down server';
4709
setAdminUpdateBadge(0);
4710
4656
4711
4657
try
4712
4658
{
@@ -4714,11 +4660,6 @@ async function refreshAdminUpdateStatus (opts = {})
4714
4660
if (!data) return;
4715
4661
_adminUpdateStatus = data;
4716
4662
4717
const updateCount = (data.underSystemd && Array.isArray(data.commitsAhead))
4718
? data.commitsAhead.length
4719
: 0;
4720
setAdminUpdateBadge(updateCount);
4721
4722
4663
if (!data.underSystemd)
4723
4664
{
4724
4665
btn.textContent = 'Shut down server';
@@ -4730,7 +4671,6 @@ async function refreshAdminUpdateStatus (opts = {})
4730
4671
else
4731
4672
{
4732
4673
btn.textContent = 'Restart & Update';
4733
if (pulseIfUpdateAvailable) pulseAdminUpdateButton();
4734
4674
}
4735
4675
}
4736
4676
catch
@@ -1536,14 +1536,6 @@ function showApp ()1536
openFolderSidebar();1536
openFolderSidebar();1537
}1537
}1538
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);1538
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);1539
if (STATE.isAdmin)1540
{1541
void refreshAdminUpdateStatus();1542
}1543
else1544
{1545
setAdminUpdateBadge(0);1546
}1547
startAutoRefresh();1539
startAutoRefresh();1548
}1540
}1549
1541
@@ -1667,8 +1659,6 @@ async function performLogout ()1667
STATE.restoreDir = null;1659
STATE.restoreDir = null;1668
STATE.restoreRootPath = null;1660
STATE.restoreRootPath = null;1669
STATE.lastOperationAt = null;1661
STATE.lastOperationAt = null;1670
_adminUpdateStatus = null;1671
setAdminUpdateBadge(0);1672
clearSessionState();1662
clearSessionState();1673
closePreview({ force: true });1663
closePreview({ force: true });1674
closeSidebar();1664
closeSidebar();@@ -4583,54 +4573,12 @@ async function deleteItem (item)4583
4573
4584
let _adminUpdateStatus = null;4574
let _adminUpdateStatus = null;4585
4575
4586
function setAdminUpdateBadge (count)4587
{4588
const badge = document.getElementById('admin-update-badge');4589
const adminBtn = document.getElementById('btn-admin');4590
if (!badge || !adminBtn) return;4591
4592
if (!STATE.isAdmin || !Number.isFinite(count) || count <= 0)4593
{4594
badge.classList.add('hidden');4595
badge.textContent = '';4596
adminBtn.removeAttribute('data-update-count');4597
return;4598
}4599
4600
const whole = Math.floor(count);4601
const capped = Math.min(whole, 99);4602
badge.textContent = capped >= 99 ? '99+' : String(capped);4603
badge.classList.remove('hidden');4604
adminBtn.dataset.updateCount = String(whole);4605
}4606
4607
function pulseAdminUpdateButton ()4608
{4609
const btn = document.getElementById('admin-shutdown-btn');4610
if (!btn) return;4611
4612
if (typeof btn.scrollIntoView === 'function')4613
{4614
btn.scrollIntoView({ behavior: 'smooth', block: 'center' });4615
}4616
4617
btn.classList.remove('admin-update-highlight');4618
// Force reflow so repeated openings can replay the pulse animation.4619
void btn.offsetWidth;4620
btn.classList.add('admin-update-highlight');4621
4622
setTimeout(() =>4623
{4624
btn.classList.remove('admin-update-highlight');4625
}, 1800);4626
}4627
4628
async function openAdminModal ()4576
async function openAdminModal ()4629
{4577
{4630
document.getElementById('admin-modal').classList.remove('hidden');4578
document.getElementById('admin-modal').classList.remove('hidden');4631
await refreshAdminConfig();4579
await refreshAdminConfig();4632
await refreshAdminUsers();4580
await refreshAdminUsers();4633
await refreshAdminUpdateStatus({ pulseIfUpdateAvailable: true });4581
void refreshAdminUpdateStatus();4634
}4582
}4635
4583
4636
async function refreshAdminConfig ()4584
async function refreshAdminConfig ()@@ -4700,13 +4648,11 @@ async function refreshAdminUsers ()4700
}4648
}4701
}4649
}4702
4650
4703
async function refreshAdminUpdateStatus (opts = {})4651
async function refreshAdminUpdateStatus ()4704
{4652
{4705
const pulseIfUpdateAvailable = !!opts.pulseIfUpdateAvailable;4706
const btn = document.getElementById('admin-shutdown-btn');4653
const btn = document.getElementById('admin-shutdown-btn');4707
_adminUpdateStatus = null;4654
_adminUpdateStatus = null;4708
btn.textContent = 'Shut down server';4655
btn.textContent = 'Shut down server';4709
setAdminUpdateBadge(0);4710
4656
4711
try4657
try4712
{4658
{@@ -4714,11 +4660,6 @@ async function refreshAdminUpdateStatus (opts = {})4714
if (!data) return;4660
if (!data) return;4715
_adminUpdateStatus = data;4661
_adminUpdateStatus = data;4716
4662
4717
const updateCount = (data.underSystemd && Array.isArray(data.commitsAhead))4718
? data.commitsAhead.length4719
: 0;4720
setAdminUpdateBadge(updateCount);4721
4722
if (!data.underSystemd)4663
if (!data.underSystemd)4723
{4664
{4724
btn.textContent = 'Shut down server';4665
btn.textContent = 'Shut down server';@@ -4730,7 +4671,6 @@ async function refreshAdminUpdateStatus (opts = {})4730
else4671
else4731
{4672
{4732
btn.textContent = 'Restart & Update';4673
btn.textContent = 'Restart & Update';4733
if (pulseIfUpdateAvailable) pulseAdminUpdateButton();4734
}4674
}4735
}4675
}4736
catch4676
catch@@ -26,7 +26,7 @@ function ensureImageDataGlobal ()
26
26
27
27
class ImageDataPolyfill
28
28
{
29
constructor(data, width, height)
29
constructor (data, width, height)
30
30
{
31
31
this.data = data;
32
32
this.width = width;
@@ -420,7 +420,38 @@ async function renderImageSubtitleFrame (options)
420
420
return frame;
421
421
}
422
422
423
function clearCachesForFile (filePath)
424
{
425
const normalised = String(filePath || '').trim();
426
if (!normalised) return;
427
428
const keysToDelete = [];
429
430
for (const key of eventCache.keys())
431
{
432
if (key.startsWith(normalised))
433
{
434
keysToDelete.push(key);
435
}
436
}
437
438
for (const key of frameCache.keys())
439
{
440
if (key.startsWith(normalised))
441
{
442
keysToDelete.push(key);
443
}
444
}
445
446
for (const key of keysToDelete)
447
{
448
eventCache.delete(key);
449
frameCache.delete(key);
450
}
451
}
452
423
453
module.exports = {
424
454
parseRenderOptions,
425
455
renderImageSubtitleFrame,
456
clearCachesForFile,
426
457
};
@@ -26,7 +26,7 @@ function ensureImageDataGlobal ()26
26
27
class ImageDataPolyfill27
class ImageDataPolyfill28
{28
{29
constructor(data, width, height)29
constructor (data, width, height)30
{30
{31
this.data = data;31
this.data = data;32
this.width = width;32
this.width = width;@@ -420,7 +420,38 @@ async function renderImageSubtitleFrame (options)420
return frame;420
return frame;421
}421
}422
422
423
function clearCachesForFile (filePath)424
{425
const normalised = String(filePath || '').trim();426
if (!normalised) return;427
428
const keysToDelete = [];429
430
for (const key of eventCache.keys())431
{432
if (key.startsWith(normalised))433
{434
keysToDelete.push(key);435
}436
}437
438
for (const key of frameCache.keys())439
{440
if (key.startsWith(normalised))441
{442
keysToDelete.push(key);443
}444
}445
446
for (const key of keysToDelete)447
{448
eventCache.delete(key);449
frameCache.delete(key);450
}451
}452
423
module.exports = {453
module.exports = {424
parseRenderOptions,454
parseRenderOptions,425
renderImageSubtitleFrame,455
renderImageSubtitleFrame,456
clearCachesForFile,426
};457
};@@ -5,6 +5,7 @@ const crypto = require('crypto');
5
5
const fs = require('fs');
6
6
const os = require('os');
7
7
const path = require('path');
8
const { clearCachesForFile } = require('./image-subtitles');
8
9
9
10
const STREAM_ROOT_DIR = path.join(os.tmpdir(), 'filemanager-video-streams');
10
11
const STREAM_SESSION_TTL_MS = 30 * 60 * 1000;
@@ -206,6 +207,10 @@ function destroySession (sessionId)
206
207
}
207
208
208
209
fs.rmSync(session.outputDir, { recursive: true, force: true });
210
211
// Clear image subtitle caches associated with this file.
212
clearCachesForFile(session.sourcePath);
213
209
214
return true;
210
215
}
211
216
@@ -5,6 +5,7 @@ const crypto = require('crypto');5
const fs = require('fs');5
const fs = require('fs');6
const os = require('os');6
const os = require('os');7
const path = require('path');7
const path = require('path');8
const { clearCachesForFile } = require('./image-subtitles');8
9
9
const STREAM_ROOT_DIR = path.join(os.tmpdir(), 'filemanager-video-streams');10
const STREAM_ROOT_DIR = path.join(os.tmpdir(), 'filemanager-video-streams');10
const STREAM_SESSION_TTL_MS = 30 * 60 * 1000;11
const STREAM_SESSION_TTL_MS = 30 * 60 * 1000;@@ -206,6 +207,10 @@ function destroySession (sessionId)206
}207
}207
208
208
fs.rmSync(session.outputDir, { recursive: true, force: true });209
fs.rmSync(session.outputDir, { recursive: true, force: true });210
211
// Clear image subtitle caches associated with this file.212
clearCachesForFile(session.sourcePath);213
209
return true;214
return true;210
}215
}211
216