don't delete channel watermarks that are still used (#2781)

* don't delete channel watermarks that are still used

* fix folder cleanup check
This commit is contained in:
Jason Dove
2026-01-16 14:24:03 -06:00
committed by GitHub
parent 7f361d1ea9
commit 3f4c9e063b
@@ -49,6 +49,17 @@ public class DeleteOrphanedArtworkHandler(
System.Collections.Generic.HashSet<string> validFiles = [];
List<string> watermarks = await dbContext.ChannelWatermarks
.TagWithCallSite()
.AsNoTracking()
.Select(c => c.Image)
.ToListAsync(cancellationToken);
foreach (string watermark in watermarks.Where(w => !string.IsNullOrWhiteSpace(w)))
{
validFiles.Add(watermark);
}
var lastId = 0;
while (true)
{
@@ -142,7 +153,15 @@ public class DeleteOrphanedArtworkHandler(
{
try
{
fileSystem.Directory.Delete(path);
// don't delete artwork cache folder or its direct children
if (path != FileSystemLayout.ArtworkCacheFolder)
{
var parent = fileSystem.Directory.GetParent(path);
if (parent?.FullName != FileSystemLayout.ArtworkCacheFolder)
{
fileSystem.Directory.Delete(path);
}
}
}
catch (Exception ex)
{