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