fix bug that causesd stale media (not on disk) to be suggested to workers
This commit is contained in:
parent
2ffbd2f50e
commit
13471e21fb
@ -64,7 +64,7 @@ public class CoverageController : ControllerBase
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.Path))
|
||||
if (!TasksController.MediaFileExists(item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Plugin.JRay.Models;
|
||||
@ -66,7 +67,7 @@ public class TasksController : ControllerBase
|
||||
// drop anything ignored, and order prioritised items ahead of the rest.
|
||||
// Randomise within each tier so the backlog still spreads across workers.
|
||||
var pending = items
|
||||
.Where(item => !string.IsNullOrEmpty(item.Path) && !_truthDataService.HasTruth(item.Id, item.Path))
|
||||
.Where(item => MediaFileExists(item) && !_truthDataService.HasTruth(item.Id, item.Path))
|
||||
.Select(item => new
|
||||
{
|
||||
Item = item,
|
||||
@ -96,4 +97,35 @@ public class TasksController : ControllerBase
|
||||
{
|
||||
return item is Episode episode ? episode.SeriesId : Guid.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether an item's backing media still exists on disk.
|
||||
/// <para>
|
||||
/// A library item can outlive its file: deleting media from disk does not
|
||||
/// always purge the Jellyfin database entry, and such ghosts keep
|
||||
/// <c>IsVirtualItem == false</c>, so filtering on that flag alone is not
|
||||
/// enough. Without this check the pending endpoint hands stale paths/URLs to
|
||||
/// extraction workers, and — because a missing file can never gain truth
|
||||
/// data — those items stay pending forever.
|
||||
/// </para>
|
||||
/// Only local (file-protocol) items are stat-checked; remote/streamed items
|
||||
/// are assumed present so we never stat something off-box.
|
||||
/// </summary>
|
||||
/// <param name="item">The library item.</param>
|
||||
/// <returns><c>true</c> if the item has usable backing media; otherwise <c>false</c>.</returns>
|
||||
internal static bool MediaFileExists(BaseItem item)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.Path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item.IsFileProtocol)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Path may point at a file or, for folder-based media, a directory.
|
||||
return System.IO.File.Exists(item.Path) || Directory.Exists(item.Path);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user