🔧 Cache içinde boş kalan thumbnail klasörlerini de temizle.
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -51,11 +51,15 @@ desktop.ini
|
||||
|
||||
# Media / Download directories (depending on your setup)
|
||||
downloads/
|
||||
server/cache/
|
||||
movie/movieData/
|
||||
movie/movieData/**/subtitles/
|
||||
movie/movieData/**/poster.jpg
|
||||
movie/movieData/**/backdrop.jpg
|
||||
|
||||
# Generic placeholders
|
||||
*.gitkeep
|
||||
|
||||
# Torrent / upload temp files
|
||||
/uploads/
|
||||
/uploads/*
|
||||
|
||||
@@ -152,21 +152,6 @@ function removeThumbnailsForPath(relPath) {
|
||||
const normalized = sanitizeRelative(relPath);
|
||||
if (!normalized) return;
|
||||
|
||||
const directDirs = [
|
||||
path.join(VIDEO_THUMB_ROOT, normalized),
|
||||
path.join(IMAGE_THUMB_ROOT, normalized)
|
||||
];
|
||||
|
||||
for (const target of directDirs) {
|
||||
try {
|
||||
if (fs.existsSync(target) && fs.lstatSync(target).isDirectory()) {
|
||||
fs.rmSync(target, { recursive: true, force: true });
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(`⚠️ Thumbnail klasörü silinemedi (${target}): ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
const parsed = path.parse(normalized);
|
||||
const candidates = [
|
||||
path.join(VIDEO_THUMB_ROOT, parsed.dir, `${parsed.name}.jpg`),
|
||||
@@ -180,6 +165,31 @@ function removeThumbnailsForPath(relPath) {
|
||||
console.warn(`⚠️ Thumbnail silinemedi (${candidate}): ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
const potentialDirs = [
|
||||
path.join(VIDEO_THUMB_ROOT, parsed.dir),
|
||||
path.join(IMAGE_THUMB_ROOT, parsed.dir)
|
||||
];
|
||||
|
||||
for (const dirPath of potentialDirs) {
|
||||
cleanupEmptyDirs(dirPath);
|
||||
}
|
||||
}
|
||||
|
||||
function cleanupEmptyDirs(startDir) {
|
||||
let dir = startDir;
|
||||
while (
|
||||
dir &&
|
||||
dir.startsWith(THUMBNAIL_DIR) &&
|
||||
fs.existsSync(dir) &&
|
||||
fs.lstatSync(dir).isDirectory()
|
||||
) {
|
||||
const entries = fs.readdirSync(dir);
|
||||
if (entries.length > 0) break;
|
||||
fs.rmdirSync(dir);
|
||||
dir = path.dirname(dir);
|
||||
if (dir === THUMBNAIL_DIR || dir === path.dirname(THUMBNAIL_DIR)) break;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveThumbnailAbsolute(relThumbPath) {
|
||||
|
||||
Reference in New Issue
Block a user