BlueGit

timfa filemanager

Allow debug-log file deletion for admins

Admins can now delete subtitle debug log files from the debug browsing flow. This removes access-denied failures from the debug menu and adds route coverage to prevent regressions.

timfa Tim Falken · pushed by timfa

Authored 2026-05-25 · 5 months ago

Hash
719ffd79b6dc9403daa5b08d39117c7e9305645b
Parent
d5a02468
3 files changed +28 −2
.github/technical-reference.md +1 −1
@@ -91,7 +91,7 @@
91 91 - applyListAccessChmod(startDir) - Best-effort shallow chmod pass for folder-access requests; updates the opened folder and its direct children only, skips symlinks, and continues past individual errors.
92 92 - resolveRootForUser(absPath, roots, user, config) - Resolves access for configured roots plus user-owned personal folder.
93 93 - resolveRootForUser(absPath, roots, user, config) - Allows admins to access orphaned user folders (deleted-account folders) under userPath.
94 - resolveRootForUser(absPath, roots, user, config) - Treats the local subtitle debug log directory as an admin-only read-only browse root for the debug menu.
94 - resolveRootForUser(absPath, roots, user, config) - Treats the local subtitle debug log directory as an admin-only debug root for browse and maintenance actions from the debug menu.
95 95 - canReadInfo(user, info) / canWriteInfo(user, info) - Permission checks that automatically allow access for personal user-folder roots.
96 96 - checkUserFolderSizeLimit(config, username, addedBytes) - Validates a user-folder capacity limit against current usage.
97 97 - POST /api/files/root-alias - Sets a display-only alias for an exact configured root path (no filesystem rename).
@@ -91,7 +91,7 @@
91- applyListAccessChmod(startDir) - Best-effort shallow chmod pass for folder-access requests; updates the opened folder and its direct children only, skips symlinks, and continues past individual errors.
91- applyListAccessChmod(startDir) - Best-effort shallow chmod pass for folder-access requests; updates the opened folder and its direct children only, skips symlinks, and continues past individual errors.
92- resolveRootForUser(absPath, roots, user, config) - Resolves access for configured roots plus user-owned personal folder.
92- resolveRootForUser(absPath, roots, user, config) - Resolves access for configured roots plus user-owned personal folder.
93- resolveRootForUser(absPath, roots, user, config) - Allows admins to access orphaned user folders (deleted-account folders) under userPath.
93- resolveRootForUser(absPath, roots, user, config) - Allows admins to access orphaned user folders (deleted-account folders) under userPath.
94- resolveRootForUser(absPath, roots, user, config) - Treats the local subtitle debug log directory as an admin-only read-only browse root for the debug menu.
94- resolveRootForUser(absPath, roots, user, config) - Treats the local subtitle debug log directory as an admin-only debug root for browse and maintenance actions from the debug menu.
95- canReadInfo(user, info) / canWriteInfo(user, info) - Permission checks that automatically allow access for personal user-folder roots.
95- canReadInfo(user, info) / canWriteInfo(user, info) - Permission checks that automatically allow access for personal user-folder roots.
96- checkUserFolderSizeLimit(config, username, addedBytes) - Validates a user-folder capacity limit against current usage.
96- checkUserFolderSizeLimit(config, username, addedBytes) - Validates a user-folder capacity limit against current usage.
97- POST /api/files/root-alias - Sets a display-only alias for an exact configured root path (no filesystem rename).
97- POST /api/files/root-alias - Sets a display-only alias for an exact configured root path (no filesystem rename).
server/routes/files.js +1 −1
@@ -711,7 +711,7 @@ function canWriteInfo (user, info)
711 711 if (!info) return false;
712 712 if (info.isUserFolder) return true;
713 713 if (info.isOrphanUserFolder) return !!(user && user.isAdmin);
714 if (info.isDebugLogFolder) return false;
714 if (info.isDebugLogFolder) return !!(user && user.isAdmin);
715 715 return canWrite(user, info.label);
716 716 }
717 717
@@ -711,7 +711,7 @@ function canWriteInfo (user, info)
711 if (!info) return false;
711 if (!info) return false;
712 if (info.isUserFolder) return true;
712 if (info.isUserFolder) return true;
713 if (info.isOrphanUserFolder) return !!(user && user.isAdmin);
713 if (info.isOrphanUserFolder) return !!(user && user.isAdmin);
714 if (info.isDebugLogFolder) return false;
714 if (info.isDebugLogFolder) return !!(user && user.isAdmin);
715 return canWrite(user, info.label);
715 return canWrite(user, info.label);
716}
716}
717
717
tests/files.routes.test.js +26 −0
@@ -777,6 +777,32 @@ describe('subtitle debug cache access', () =>
777 777 }
778 778 });
779 779
780 test('admins can delete files in the subtitle debug cache folder', async () =>
781 {
782 const logDir = path.join(os.tmpdir(), 'filemanager-subtitle-debug-logs');
783 const logFile = path.join(logDir, '2026-05-25-delete-me-subtitlelog.txt');
784 fs.rmSync(logDir, { recursive: true, force: true });
785 fs.mkdirSync(logDir, { recursive: true });
786 fs.writeFileSync(logFile, 'delete me');
787
788 mockUser = {
789 username: 'admin',
790 isAdmin: true,
791 permissions: {},
792 };
793
794 try
795 {
796 const deleteRes = await req('POST', '/api/files/delete', { path: logFile });
797 expect(deleteRes.status).toBe(200);
798 expect(deleteRes.body).toEqual({ ok: true });
799 expect(fs.existsSync(logFile)).toBe(false);
800 } finally
801 {
802 fs.rmSync(logDir, { recursive: true, force: true });
803 }
804 });
805
780 806 test('non-admin users cannot browse the subtitle debug cache folder', async () =>
781 807 {
782 808 const logDir = path.join(os.tmpdir(), 'filemanager-subtitle-debug-logs');
@@ -777,6 +777,32 @@ describe('subtitle debug cache access', () =>
777 }
777 }
778 });
778 });
779
779
780 test('admins can delete files in the subtitle debug cache folder', async () =>
781 {
782 const logDir = path.join(os.tmpdir(), 'filemanager-subtitle-debug-logs');
783 const logFile = path.join(logDir, '2026-05-25-delete-me-subtitlelog.txt');
784 fs.rmSync(logDir, { recursive: true, force: true });
785 fs.mkdirSync(logDir, { recursive: true });
786 fs.writeFileSync(logFile, 'delete me');
787
788 mockUser = {
789 username: 'admin',
790 isAdmin: true,
791 permissions: {},
792 };
793
794 try
795 {
796 const deleteRes = await req('POST', '/api/files/delete', { path: logFile });
797 expect(deleteRes.status).toBe(200);
798 expect(deleteRes.body).toEqual({ ok: true });
799 expect(fs.existsSync(logFile)).toBe(false);
800 } finally
801 {
802 fs.rmSync(logDir, { recursive: true, force: true });
803 }
804 });
805
780 test('non-admin users cannot browse the subtitle debug cache folder', async () =>
806 test('non-admin users cannot browse the subtitle debug cache folder', async () =>
781 {
807 {
782 const logDir = path.join(os.tmpdir(), 'filemanager-subtitle-debug-logs');
808 const logDir = path.join(os.tmpdir(), 'filemanager-subtitle-debug-logs');