fix: manifest saving on load failure and thumbnail removal (#142)

This commit is contained in:
Whitewater
2025-11-03 12:46:44 +08:00
committed by GitHub
parent a9119b2811
commit 757ebd900c

View File

@@ -19,6 +19,7 @@ export async function loadExistingManifest(): Promise<AfilmoryManifest> {
manifest = JSON.parse(manifestContent) as AfilmoryManifest
} catch {
logger.fs.error('🔍 未找到 manifest 文件/解析失败,创建新的 manifest 文件...')
await saveManifest([])
return {
version: CURRENT_MANIFEST_VERSION,
data: [],
@@ -87,7 +88,7 @@ export async function handleDeletedPhotos(items: PhotoManifestItem[]): Promise<n
logger.main.info('🔍 检查已删除的图片...')
if (items.length === 0) {
// Clear all thumbnails
await fs.rm(path.join(workdir, 'public/thumbnails'), { recursive: true })
await fs.rm(path.join(workdir, 'public/thumbnails'), { recursive: true, force: true })
logger.main.info('🔍 没有图片,清空缩略图...')
return 0
}