Compare commits

..

No commits in common. "caa0d1eab93da3a94ad86e750cb2366d4069e1ba" and "90fe3c8fb9668eeaf3d4f9275506b099a1831326" have entirely different histories.

4 changed files with 16 additions and 31 deletions

BIN
media.db

Binary file not shown.

View File

@ -31,10 +31,9 @@ export async function GET(request: Request) {
const ext = path.extname(file).toLowerCase();
let type = 'file';
const cleanExt = ext.replace('.', '').toLowerCase();
if (VIDEO_EXTENSIONS.some(v => v.toLowerCase() === cleanExt)) {
if (VIDEO_EXTENSIONS.some(v => ext.includes(v))) {
type = 'video';
} else if (PHOTO_EXTENSIONS.some(p => p.toLowerCase() === cleanExt)) {
} else if (PHOTO_EXTENSIONS.some(p => ext.includes(p))) {
type = 'photo';
}

View File

@ -174,18 +174,12 @@ const FolderViewerPage = () => {
// Don't allow navigation above library root
if (currentPath === libraryRoot) return '';
// Split path but keep leading slash for absolute paths
const pathParts = currentPath.split('/');
const pathParts = currentPath.split('/').filter(part => part.length > 0);
const libraryParts = libraryRoot.split('/').filter(part => part.length > 0);
// Filter out empty parts but keep structure
const filteredPathParts = pathParts.filter(part => part.length > 0);
if (pathParts.length <= libraryParts.length) return '';
if (filteredPathParts.length <= libraryParts.length) return '';
// Reconstruct absolute path
const parentParts = filteredPathParts.slice(0, -1);
return '/' + parentParts.join('/');
return pathParts.slice(0, -1).join('/');
};
const handleBackClick = () => {

View File

@ -34,32 +34,24 @@ const generatePhotoThumbnail = (photoPath: string, thumbnailPath: string) => {
};
const scanLibrary = async (library: { id: number; path: string }) => {
// Scan videos - handle all case variations
const videoFiles = await glob(`${library.path}/**/*.*`, { nodir: true });
// Scan photos - handle all case variations
const photoFiles = await glob(`${library.path}/**/*.*`, { nodir: true });
// Filter files by extension (case-insensitive)
const filteredVideoFiles = videoFiles.filter(file => {
const ext = path.extname(file).toLowerCase().replace('.', '');
return VIDEO_EXTENSIONS.includes(ext);
// Scan videos
const videoFiles = await glob(`${library.path}/**/*.{${VIDEO_EXTENSIONS.join(",")}}`, {
nodir: true,
});
const filteredPhotoFiles = photoFiles.filter(file => {
const ext = path.extname(file).toLowerCase().replace('.', '');
return PHOTO_EXTENSIONS.includes(ext);
// Scan photos
const photoFiles = await glob(`${library.path}/**/*.{${PHOTO_EXTENSIONS.join(",")}}`, {
nodir: true,
});
const allFiles = [...filteredVideoFiles, ...filteredPhotoFiles];
const allFiles = [...videoFiles, ...photoFiles];
for (const file of allFiles) {
const stats = fs.statSync(file);
const title = path.basename(file);
const ext = path.extname(file).toLowerCase();
const cleanExt = ext.replace('.', '').toLowerCase();
const isVideo = VIDEO_EXTENSIONS.some(v => v.toLowerCase() === cleanExt);
const isPhoto = PHOTO_EXTENSIONS.some(p => p.toLowerCase() === cleanExt);
const isVideo = VIDEO_EXTENSIONS.some(v => ext.includes(v));
const isPhoto = PHOTO_EXTENSIONS.some(p => ext.includes(p));
const mediaType = isVideo ? "video" : "photo";
const thumbnailFileName = `${path.parse(title).name}_${Date.now()}.png`;