mirror of
https://github.com/Radarr/Radarr.git
synced 2025-04-23 22:17:15 -04:00
Fixed: Ignore special folders inside Blackhole watch folders
(cherry picked from commit e79dd6f8e689617b1fd9f96c639ac300669112c5)
This commit is contained in:
parent
405ae77070
commit
c7aa1bae5e
4 changed files with 72 additions and 33 deletions
|
@ -17,37 +17,6 @@ namespace NzbDrone.Common.Disk
|
|||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IRuntimeInfo _runtimeInfo;
|
||||
|
||||
private readonly HashSet<string> _setToRemove = new HashSet<string>
|
||||
{
|
||||
// Windows
|
||||
"boot",
|
||||
"bootmgr",
|
||||
"cache",
|
||||
"msocache",
|
||||
"recovery",
|
||||
"$recycle.bin",
|
||||
"recycler",
|
||||
"system volume information",
|
||||
"temporary internet files",
|
||||
"windows",
|
||||
|
||||
// OS X
|
||||
".fseventd",
|
||||
".spotlight",
|
||||
".trashes",
|
||||
".vol",
|
||||
"cachedmessages",
|
||||
"caches",
|
||||
"trash",
|
||||
|
||||
// QNAP
|
||||
".@__thumb",
|
||||
|
||||
// Synology
|
||||
"@eadir",
|
||||
"#recycle"
|
||||
};
|
||||
|
||||
public FileSystemLookupService(IDiskProvider diskProvider, IRuntimeInfo runtimeInfo)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
|
@ -158,7 +127,7 @@ namespace NzbDrone.Common.Disk
|
|||
})
|
||||
.ToList();
|
||||
|
||||
directories.RemoveAll(d => _setToRemove.Contains(d.Name.ToLowerInvariant()));
|
||||
directories.RemoveAll(d => SpecialFolders.IsSpecialFolder(d.Name));
|
||||
|
||||
return directories;
|
||||
}
|
||||
|
|
47
src/NzbDrone.Common/Disk/SpecialFolders.cs
Normal file
47
src/NzbDrone.Common/Disk/SpecialFolders.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Common.Disk;
|
||||
|
||||
public static class SpecialFolders
|
||||
{
|
||||
private static readonly HashSet<string> _specialFolders = new HashSet<string>
|
||||
{
|
||||
// Windows
|
||||
"boot",
|
||||
"bootmgr",
|
||||
"cache",
|
||||
"msocache",
|
||||
"recovery",
|
||||
"$recycle.bin",
|
||||
"recycler",
|
||||
"system volume information",
|
||||
"temporary internet files",
|
||||
"windows",
|
||||
|
||||
// OS X
|
||||
".fseventd",
|
||||
".spotlight",
|
||||
".trashes",
|
||||
".vol",
|
||||
"cachedmessages",
|
||||
"caches",
|
||||
"trash",
|
||||
|
||||
// QNAP
|
||||
".@__thumb",
|
||||
|
||||
// Synology
|
||||
"@eadir",
|
||||
"#recycle"
|
||||
};
|
||||
|
||||
public static bool IsSpecialFolder(string folder)
|
||||
{
|
||||
if (folder == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _specialFolders.Contains(folder.ToLowerInvariant());
|
||||
}
|
||||
}
|
|
@ -95,5 +95,22 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
|
||||
VerifySingleItem(DownloadItemStatus.Completed);
|
||||
}
|
||||
|
||||
[TestCase("@eaDir")]
|
||||
[TestCase(".@__thumb")]
|
||||
public void GetItems_should_not_include_special_subfolders(string folderName)
|
||||
{
|
||||
GivenCompletedItem();
|
||||
|
||||
var targetDir = Path.Combine(_completedDownloadFolder, folderName);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.GetDirectories(_completedDownloadFolder))
|
||||
.Returns(new[] { targetDir });
|
||||
|
||||
var items = Subject.GetItems(_completedDownloadFolder, TimeSpan.FromMilliseconds(50)).ToList();
|
||||
|
||||
items.Count.Should().Be(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,13 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
|||
{
|
||||
foreach (var folder in _diskScanService.FilterPaths(watchFolder, _diskProvider.GetDirectories(watchFolder)))
|
||||
{
|
||||
var title = FileNameBuilder.CleanFileName(Path.GetFileName(folder));
|
||||
var folderName = Path.GetFileName(folder);
|
||||
var title = FileNameBuilder.CleanFileName(folderName);
|
||||
|
||||
if (SpecialFolders.IsSpecialFolder(folderName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var newWatchItem = new WatchFolderItem
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue