feat: Add library ID support to media scanner and worker

Add default library ID functionality to improve library targeting
during media scans.

Service changes in internal/services/media_scanner.go:
- Add defaultLibraryID field to MediaScanner struct
- Add SetLibraryID() method to set default library
- Modify processMediaFile() to use defaultLibraryID when set
  - Prioritizes defaultLibraryID over folder-based library detection
  - Provides explicit library targeting for scans

Service changes in internal/services/worker.go:
- Add libraryUUID conversion from string to pgtype.UUID
- Call scanner.SetLibraryID() before ScanFolders()
  - Ensures scanner respects the job's library ID

These changes enable more precise library targeting during media scans,
allowing scans to be directed to specific libraries rather than relying
solely on folder-based detection.
This commit is contained in:
2026-03-01 00:29:39 -05:00
parent eb2da1e05b
commit c6fa217092
22 changed files with 230 additions and 206 deletions
+31 -29
View File
@@ -1,24 +1,24 @@
"use strict";
// Header functionality
const toggleThemeDropdown = () => {
const dropdown = document.getElementById('theme-dropdown');
const dropdown = document.getElementById("theme-dropdown");
if (dropdown) {
dropdown.classList.toggle('hidden');
dropdown.classList.toggle("hidden");
// Close user menu if open
const userMenu = document.getElementById('user-menu');
if (userMenu && !dropdown.classList.contains('hidden')) {
userMenu.classList.add('hidden');
const userMenu = document.getElementById("user-menu");
if (userMenu && !dropdown.classList.contains("hidden")) {
userMenu.classList.add("hidden");
}
}
};
const toggleUserMenu = () => {
const menu = document.getElementById('user-menu');
const menu = document.getElementById("user-menu");
if (menu) {
menu.classList.toggle('hidden');
menu.classList.toggle("hidden");
// Close theme dropdown if open
const themeDropdown = document.getElementById('theme-dropdown');
if (themeDropdown && !menu.classList.contains('hidden')) {
themeDropdown.classList.add('hidden');
const themeDropdown = document.getElementById("theme-dropdown");
if (themeDropdown && !menu.classList.contains("hidden")) {
themeDropdown.classList.add("hidden");
}
}
};
@@ -28,43 +28,45 @@ const changeThemeTo = (theme) => {
window.applyTheme(theme);
}
// Save to server if logged in
const token = localStorage.getItem('token');
const token = localStorage.getItem("token");
if (token) {
fetch('/api/auth/theme', {
method: 'PUT',
fetch("/api/auth/theme", {
method: "PUT",
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ theme })
}).catch(err => console.log('Theme save failed', err));
body: JSON.stringify({ theme }),
}).catch((err) => console.log("Theme save failed", err));
}
// Close dropdown
const dropdown = document.getElementById('theme-dropdown');
const dropdown = document.getElementById("theme-dropdown");
if (dropdown) {
dropdown.classList.add('hidden');
dropdown.classList.add("hidden");
}
};
const logout = () => {
localStorage.removeItem('token');
localStorage.removeItem('user');
window.location.href = '/';
localStorage.removeItem("token");
localStorage.removeItem("user");
window.location.href = "/";
};
// Close dropdowns when clicking outside
document.addEventListener('click', (e) => {
document.addEventListener("click", (e) => {
const target = e.target;
const themeDropdown = document.getElementById('theme-dropdown');
const userMenu = document.getElementById('user-menu');
const themeDropdown = document.getElementById("theme-dropdown");
const userMenu = document.getElementById("user-menu");
const themeButton = target?.closest('button[onclick="toggleThemeDropdown()"]');
const userButton = target?.closest('button[onclick="toggleUserMenu()"]');
if (!themeButton && themeDropdown && !themeDropdown.classList.contains('hidden')) {
if (!themeButton &&
themeDropdown &&
!themeDropdown.classList.contains("hidden")) {
if (!themeDropdown.contains(target)) {
themeDropdown.classList.add('hidden');
themeDropdown.classList.add("hidden");
}
}
if (!userButton && userMenu && !userMenu.classList.contains('hidden')) {
if (!userButton && userMenu && !userMenu.classList.contains("hidden")) {
if (!userMenu.contains(target)) {
userMenu.classList.add('hidden');
userMenu.classList.add("hidden");
}
}
});