Refresh local videos on each listing request

This commit is contained in:
2026-06-15 19:44:49 -07:00
parent 0ad0df5612
commit d37694e4d3

View File

@@ -132,6 +132,8 @@ app.get('/api/favorites', (_request, response) => {
}); });
app.get('/api/local-videos', async (_request, response) => { app.get('/api/local-videos', async (_request, response) => {
response.set('Cache-Control', 'no-store');
if (!LOCAL_VIDEOS_ROOT) { if (!LOCAL_VIDEOS_ROOT) {
response.json({ enabled: false, videos: [] }); response.json({ enabled: false, videos: [] });
return; return;
@@ -658,10 +660,13 @@ function getLocalVideosRealRoot() {
} }
if (!localVideosRealRootPromise) { if (!localVideosRealRootPromise) {
localVideosRealRootPromise = fs.realpath(LOCAL_VIDEOS_ROOT).catch((error) => { localVideosRealRootPromise = fs.realpath(LOCAL_VIDEOS_ROOT)
localVideosRealRootPromise = null; .catch((error) => {
throw new Error(`Local videos directory is unavailable: ${error.message}`); throw new Error(`Local videos directory is unavailable: ${error.message}`);
}); })
.finally(() => {
localVideosRealRootPromise = null;
});
} }
return localVideosRealRootPromise; return localVideosRealRootPromise;