Refresh local videos on each listing request
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user