Compare commits
No commits in common. "caa0d1eab93da3a94ad86e750cb2366d4069e1ba" and "90fe3c8fb9668eeaf3d4f9275506b099a1831326" have entirely different histories.
caa0d1eab9
...
90fe3c8fb9
|
|
@ -31,10 +31,9 @@ export async function GET(request: Request) {
|
||||||
const ext = path.extname(file).toLowerCase();
|
const ext = path.extname(file).toLowerCase();
|
||||||
|
|
||||||
let type = 'file';
|
let type = 'file';
|
||||||
const cleanExt = ext.replace('.', '').toLowerCase();
|
if (VIDEO_EXTENSIONS.some(v => ext.includes(v))) {
|
||||||
if (VIDEO_EXTENSIONS.some(v => v.toLowerCase() === cleanExt)) {
|
|
||||||
type = 'video';
|
type = 'video';
|
||||||
} else if (PHOTO_EXTENSIONS.some(p => p.toLowerCase() === cleanExt)) {
|
} else if (PHOTO_EXTENSIONS.some(p => ext.includes(p))) {
|
||||||
type = 'photo';
|
type = 'photo';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,18 +174,12 @@ const FolderViewerPage = () => {
|
||||||
// Don't allow navigation above library root
|
// Don't allow navigation above library root
|
||||||
if (currentPath === libraryRoot) return '';
|
if (currentPath === libraryRoot) return '';
|
||||||
|
|
||||||
// Split path but keep leading slash for absolute paths
|
const pathParts = currentPath.split('/').filter(part => part.length > 0);
|
||||||
const pathParts = currentPath.split('/');
|
|
||||||
const libraryParts = libraryRoot.split('/').filter(part => part.length > 0);
|
const libraryParts = libraryRoot.split('/').filter(part => part.length > 0);
|
||||||
|
|
||||||
// Filter out empty parts but keep structure
|
if (pathParts.length <= libraryParts.length) return '';
|
||||||
const filteredPathParts = pathParts.filter(part => part.length > 0);
|
|
||||||
|
|
||||||
if (filteredPathParts.length <= libraryParts.length) return '';
|
return pathParts.slice(0, -1).join('/');
|
||||||
|
|
||||||
// Reconstruct absolute path
|
|
||||||
const parentParts = filteredPathParts.slice(0, -1);
|
|
||||||
return '/' + parentParts.join('/');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBackClick = () => {
|
const handleBackClick = () => {
|
||||||
|
|
|
||||||
|
|
@ -34,32 +34,24 @@ const generatePhotoThumbnail = (photoPath: string, thumbnailPath: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const scanLibrary = async (library: { id: number; path: string }) => {
|
const scanLibrary = async (library: { id: number; path: string }) => {
|
||||||
// Scan videos - handle all case variations
|
// Scan videos
|
||||||
const videoFiles = await glob(`${library.path}/**/*.*`, { nodir: true });
|
const videoFiles = await glob(`${library.path}/**/*.{${VIDEO_EXTENSIONS.join(",")}}`, {
|
||||||
|
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);
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredPhotoFiles = photoFiles.filter(file => {
|
|
||||||
const ext = path.extname(file).toLowerCase().replace('.', '');
|
|
||||||
return PHOTO_EXTENSIONS.includes(ext);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const allFiles = [...filteredVideoFiles, ...filteredPhotoFiles];
|
// Scan photos
|
||||||
|
const photoFiles = await glob(`${library.path}/**/*.{${PHOTO_EXTENSIONS.join(",")}}`, {
|
||||||
|
nodir: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const allFiles = [...videoFiles, ...photoFiles];
|
||||||
|
|
||||||
for (const file of allFiles) {
|
for (const file of allFiles) {
|
||||||
const stats = fs.statSync(file);
|
const stats = fs.statSync(file);
|
||||||
const title = path.basename(file);
|
const title = path.basename(file);
|
||||||
const ext = path.extname(file).toLowerCase();
|
const ext = path.extname(file).toLowerCase();
|
||||||
const cleanExt = ext.replace('.', '').toLowerCase();
|
const isVideo = VIDEO_EXTENSIONS.some(v => ext.includes(v));
|
||||||
const isVideo = VIDEO_EXTENSIONS.some(v => v.toLowerCase() === cleanExt);
|
const isPhoto = PHOTO_EXTENSIONS.some(p => ext.includes(p));
|
||||||
const isPhoto = PHOTO_EXTENSIONS.some(p => p.toLowerCase() === cleanExt);
|
|
||||||
|
|
||||||
const mediaType = isVideo ? "video" : "photo";
|
const mediaType = isVideo ? "video" : "photo";
|
||||||
const thumbnailFileName = `${path.parse(title).name}_${Date.now()}.png`;
|
const thumbnailFileName = `${path.parse(title).name}_${Date.now()}.png`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue