Skip to content

[BUG] QueueCleaner crashes with DirectoryNotFoundException on missing download directories #127

@Ivoooo

Description

@Ivoooo

Tubifarry Version

v3.1.2.4913 (plugin branch)

Lidarr Version

v2.0.3.0

Operating System

Docker

Bug Description

QueueCleaner throws DirectoryNotFoundException when processing queue items whose download directories no longer exist (e.g., already imported successfully, manually deleted, or cleaned up by another process).

I observed two issues occurring simultaneously, but I cannot determine which caused which:

  1. QueueCleaner throwing repeated DirectoryNotFoundException errors - clearly visible in logs
  2. A RescanFolders command stuck in "started" state for 6+ hours - blocking all disk-access commands (ProcessMonitoredDownloads, DownloadedAlbumsScan), leaving 50+ albums stuck in importPending state

The logs from when the RescanFolders command got stuck have rotated away, so I cannot prove whether the QueueCleaner exceptions caused the stuck command, or if they are separate issues. The only way I found to solve the issue is to restart lidarr. Refreshing the queue, manually importing or anything else I tried did not fix the issue.

The error occurs in QueueCleaner.Remove() when it calls DiskProviderBase.GetFileInfos() on a path that doesn't exist. The plugin should check if the directory exists before attempting to enumerate files.

Steps to Reproduce

  1. Enable QueueCleaner in Lidarr (and switch to plugin branch)
  2. Have download items in the queue that reference directories which no longer exist on disk (e.g., from a previous import that succeeded, manual cleanup, or download client cleanup)
  3. Trigger an AlbumImportIncompleteEvent (e.g., by having a partial import or running RefreshMonitoredDownloads)
  4. QueueCleaner attempts to process stale queue entries and throws DirectoryNotFoundException

Expected Behavior

QueueCleaner should:

  1. Check if the download directory exists before attempting to enumerate files
  2. If the directory doesn't exist, gracefully skip or remove the queue item instead of throwing an exception
  3. (Potentially if the other bug is related:) Not block import processing for other valid queue iitems

Trace Log Files

I'm sorry I don't have a trace log because this issue only occurs every few days but I think this log already shows the debug issue quite clearly. I'm happy to add an update if I manage to capture the issue now with strace logs enabled. However that's quite diffucult as I can't know if the system is stuck again or just tacking a bit of time to import a large album.

Logs
[v3.1.2.4913] System.IO.DirectoryNotFoundException: Could not find a part of the path
  '/downloads/complete/music/Gabry Ponte-Thunder (Prezioso Festival
  Mix)-16BIT-44-KHZ-WEB-FLAC-2022-WALKMAN'.
     at System.IO.Enumeration.FileSystemEnumerator`1.Init()
     at System.IO.Enumeration.FileSystemEnumerableFactory.FileInfos(String directory, String
  expression, EnumerationOptions options, Boolean isNormalized)
     at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget
   searchTarget, EnumerationOptions options)
     at System.IO.DirectoryInfo.EnumerateFiles(String searchPattern, EnumerationOptions
  enumerationOptions)
     at System.IO.Abstractions.DirectoryInfoWrapper.EnumerateFiles(String searchPattern,
  EnumerationOptions enumerationOptions)
     at NzbDrone.Common.Disk.DiskProviderBase.GetFileInfos(String path, Boolean recursive) in
  ./NzbDrone.Common/Disk/DiskProviderBase.cs:line 536
     at Tubifarry.Notifications.QueueCleaner.QueueCleaner.Remove(TrackedDownload item)
     at Tubifarry.Notifications.QueueCleaner.QueueCleaner.CleanImport(AlbumImportIncompleteEvent
  message)
     at Tubifarry.Notifications.QueueCleaner.ImportFailureNotificationService.Handle(AlbumImportIncomp
  leteEvent message)

Log Checklist

  • I have enabled Trace logging in Lidarr before reproducing the issue

Screenshots

No response

Additional Context

I simultaneously: Changed to the plugin branch of Lidarr and started using Tubifarry so I can't directly say if the bugs are due to a Lidarr update or Tubifarry installation but at least this bug seems Tubifarry related.

I have no idea if this is true but Claude Code suggested:
Suggested fix location: QueueCleaner.Remove() should wrap the GetFileInfos() call with a directory
existence check:
if (!Directory.Exists(downloadPath))
{
// Directory already gone, nothing to clean up
return;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Queue CleanerFor features related to the Queue CleanerbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions