mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Special folders also apply to RootFolder unmapped folders
This commit is contained in:
parent
26dbafee08
commit
19906e0350
@ -35,8 +35,8 @@ public List<String> LookupSubDirectories(string query)
|
||||
|
||||
if (Path.GetPathRoot(path).Equals(path, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var setToRemove = new HashSet<string> { "$Recycle.Bin", "System Volume Information" };
|
||||
dirsList.RemoveAll(x => setToRemove.Contains(new DirectoryInfo(x).Name));
|
||||
var setToRemove = _diskProvider.SpecialFolders;
|
||||
dirsList.RemoveAll(x => setToRemove.Contains(new DirectoryInfo(x.ToLowerInvariant()).Name));
|
||||
}
|
||||
|
||||
dirs = dirsList;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@ -11,6 +12,7 @@ namespace NzbDrone.Common
|
||||
{
|
||||
public interface IDiskProvider
|
||||
{
|
||||
HashSet<string> SpecialFolders { get; }
|
||||
DateTime GetLastFolderWrite(string path);
|
||||
DateTime GetLastFileWrite(string path);
|
||||
void EnsureFolder(string path);
|
||||
@ -36,7 +38,7 @@ public interface IDiskProvider
|
||||
void FolderSetLastWriteTimeUtc(string path, DateTime dateTime);
|
||||
bool IsFileLocked(FileInfo file);
|
||||
string GetPathRoot(string path);
|
||||
void SetPermissions(string filename, string account, FileSystemRights Rights, AccessControlType ControlType);
|
||||
void SetPermissions(string filename, string account, FileSystemRights rights, AccessControlType controlType);
|
||||
bool IsParent(string parentfolder, string subfolder);
|
||||
FileAttributes GetFileAttributes(string path);
|
||||
}
|
||||
@ -58,6 +60,14 @@ static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public HashSet<string> SpecialFolders
|
||||
{
|
||||
get
|
||||
{
|
||||
return new HashSet<string> { "$recycle.bin", "system volume information", "recycler" };
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime GetLastFolderWrite(string path)
|
||||
{
|
||||
Ensure.That(() => path).IsValidPath();
|
||||
|
@ -99,7 +99,7 @@ public virtual List<UnmappedFolder> GetUnmappedFolders(string path)
|
||||
throw new ArgumentException("Invalid path provided", "path");
|
||||
|
||||
var results = new List<UnmappedFolder>();
|
||||
var series = _seriesRepository.All();
|
||||
var series = _seriesRepository.All().ToList();
|
||||
|
||||
if (!_diskProvider.FolderExists(path))
|
||||
{
|
||||
@ -116,6 +116,12 @@ public virtual List<UnmappedFolder> GetUnmappedFolders(string path)
|
||||
}
|
||||
}
|
||||
|
||||
if (Path.GetPathRoot(path).Equals(path, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var setToRemove = _diskProvider.SpecialFolders;
|
||||
results.RemoveAll(x => setToRemove.Contains(new DirectoryInfo(x.Path.ToLowerInvariant()).Name));
|
||||
}
|
||||
|
||||
Logger.Debug("{0} unmapped folders detected.", results.Count);
|
||||
return results;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user