From ceb651894e379661e2220f60259a443d017a276f Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 4 Oct 2025 03:00:15 -0400 Subject: [PATCH] fix(scanner): resolve dirs via CLI/env/constants; write per-item JSON; skip trash --- CHANGELOG.md | 9 ++++ public/js/adminPanel.js | 2 +- scripts/scan_uploads.php | 90 +++++++++++++++++++++++++++------------- 3 files changed, 71 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b41b892..b62baeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## Changes 10/4/2025 v1.3.13 + +fix(scanner): resolve dirs via CLI/env/constants; write per-item JSON; skip trash + +- scan_uploads.php now falls back to UPLOAD_DIR/META_DIR from config.php +- prevents double slashes in metadata paths; respects app timezone +- skips trash/profile_pics and symlinks; writes JSON only when missing +- unblocks SCAN_ON_START so externally added files are indexed at boot + ## Changes 10/4/2025 v1.3.12 Fix: robust PUID/PGID handling; optional ownership normalization (closes #43) diff --git a/public/js/adminPanel.js b/public/js/adminPanel.js index c9cae72..6f534df 100644 --- a/public/js/adminPanel.js +++ b/public/js/adminPanel.js @@ -3,7 +3,7 @@ import { loadAdminConfigFunc } from './auth.js'; import { showToast, toggleVisibility, attachEnterKeyListener } from './domUtils.js'; import { sendRequest } from './networkUtils.js'; -const version = "v1.3.12"; +const version = "v1.3.13"; const adminTitle = `${t("admin_panel")} ${version}`; // ————— Inject updated styles ————— diff --git a/scripts/scan_uploads.php b/scripts/scan_uploads.php index cb9d753..05204be 100644 --- a/scripts/scan_uploads.php +++ b/scripts/scan_uploads.php @@ -1,63 +1,95 @@ str_replace($uploadDir, '', $item), - 'type' => $type, - 'size' => $size, - 'user' => 'Imported', - 'uploadDate' => date('c') + 'path' => rtrim($relative, '/'), + 'type' => $isDir ? 'folder' : 'file', + 'size' => (!$isDir && is_file($item)) ? (int)filesize($item) : 0, + 'user' => 'Imported', + 'uploadDate' => date('c'), ]; - if (!is_dir(dirname($metaPath))) { - mkdir(dirname($metaPath), 0775, true); + // Ensure parent directory exists with sane perms (umask from start.sh handles final modes) + $parent = dirname($metaPath); + if (!is_dir($parent)) { + @mkdir($parent, 0775, true); } - file_put_contents($metaPath, json_encode($metadata, JSON_PRETTY_PRINT)); - echo "Created metadata for: {$item}\n"; + if (@file_put_contents($metaPath, json_encode($metadata, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)) === false) { + fwrite(STDERR, "Failed to write metadata: {$metaPath}\n"); + } else { + echo "Created metadata for: {$relative}\n"; + } } } -?>