mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 04:59:35 -07:00
New: Ignore inaccessible files with getting files
(cherry picked from commit e5aa8584100d96a2077c57f74ae5b2ceab63de19)
This commit is contained in:
parent
1245b2c58b
commit
5fc1fc499c
29 changed files with 113 additions and 80 deletions
|
@ -25,7 +25,7 @@ namespace Lidarr.Api.V1.Logs
|
||||||
|
|
||||||
protected override IEnumerable<string> GetLogFiles()
|
protected override IEnumerable<string> GetLogFiles()
|
||||||
{
|
{
|
||||||
return _diskProvider.GetFiles(_appFolderInfo.GetLogFolder(), SearchOption.TopDirectoryOnly);
|
return _diskProvider.GetFiles(_appFolderInfo.GetLogFolder(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetLogFilePath(string filename)
|
protected override string GetLogFilePath(string filename)
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Lidarr.Api.V1.Logs
|
||||||
return Enumerable.Empty<string>();
|
return Enumerable.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _diskProvider.GetFiles(_appFolderInfo.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly)
|
return _diskProvider.GetFiles(_appFolderInfo.GetUpdateLogFolder(), false)
|
||||||
.Where(f => Regex.IsMatch(Path.GetFileName(f), LOGFILE_ROUTE.TrimStart('/'), RegexOptions.IgnoreCase))
|
.Where(f => Regex.IsMatch(Path.GetFileName(f), LOGFILE_ROUTE.TrimStart('/'), RegexOptions.IgnoreCase))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -838,7 +838,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
||||||
|
|
||||||
// Note: never returns anything.
|
// Note: never returns anything.
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(v => v.GetFileInfos(It.IsAny<string>(), It.IsAny<SearchOption>()))
|
.Setup(v => v.GetFileInfos(It.IsAny<string>(), It.IsAny<bool>()))
|
||||||
.Returns(new List<IFileInfo>());
|
.Returns(new List<IFileInfo>());
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
@ -878,8 +878,8 @@ namespace NzbDrone.Common.Test.DiskTests
|
||||||
.Returns<string>(v => fileSystem.DirectoryInfo.FromDirectoryName(v).GetDirectories().ToList());
|
.Returns<string>(v => fileSystem.DirectoryInfo.FromDirectoryName(v).GetDirectories().ToList());
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(v => v.GetFileInfos(It.IsAny<string>(), It.IsAny<SearchOption>()))
|
.Setup(v => v.GetFileInfos(It.IsAny<string>(), It.IsAny<bool>()))
|
||||||
.Returns((string v, SearchOption option) => fileSystem.DirectoryInfo.FromDirectoryName(v).GetFiles("*", option).ToList());
|
.Returns((string v, bool recursive) => fileSystem.DirectoryInfo.FromDirectoryName(v).GetFiles("*", new EnumerationOptions { RecurseSubdirectories = recursive }).ToList());
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(v => v.GetFileSize(It.IsAny<string>()))
|
.Setup(v => v.GetFileSize(It.IsAny<string>()))
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using ICSharpCode.SharpZipLib.Core;
|
using ICSharpCode.SharpZipLib.Core;
|
||||||
using ICSharpCode.SharpZipLib.GZip;
|
using ICSharpCode.SharpZipLib.GZip;
|
||||||
|
@ -11,7 +12,7 @@ namespace NzbDrone.Common
|
||||||
public interface IArchiveService
|
public interface IArchiveService
|
||||||
{
|
{
|
||||||
void Extract(string compressedFile, string destination);
|
void Extract(string compressedFile, string destination);
|
||||||
void CreateZip(string path, params string[] files);
|
void CreateZip(string path, IEnumerable<string> files);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ArchiveService : IArchiveService
|
public class ArchiveService : IArchiveService
|
||||||
|
@ -39,7 +40,7 @@ namespace NzbDrone.Common
|
||||||
_logger.Debug("Extraction complete.");
|
_logger.Debug("Extraction complete.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateZip(string path, params string[] files)
|
public void CreateZip(string path, IEnumerable<string> files)
|
||||||
{
|
{
|
||||||
using (var zipFile = ZipFile.Create(path))
|
using (var zipFile = ZipFile.Create(path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace NzbDrone.Common.Disk
|
||||||
{
|
{
|
||||||
CheckFolderExists(path);
|
CheckFolderExists(path);
|
||||||
|
|
||||||
var dirFiles = GetFiles(path, SearchOption.AllDirectories).ToList();
|
var dirFiles = GetFiles(path, true).ToList();
|
||||||
|
|
||||||
if (!dirFiles.Any())
|
if (!dirFiles.Any())
|
||||||
{
|
{
|
||||||
|
@ -156,11 +156,11 @@ namespace NzbDrone.Common.Disk
|
||||||
return _fileSystem.Directory.EnumerateFileSystemEntries(path).Empty();
|
return _fileSystem.Directory.EnumerateFileSystemEntries(path).Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] GetDirectories(string path)
|
public IEnumerable<string> GetDirectories(string path)
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||||
|
|
||||||
return _fileSystem.Directory.GetDirectories(path);
|
return _fileSystem.Directory.EnumerateDirectories(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] GetDirectories(string path, SearchOption searchOption)
|
public string[] GetDirectories(string path, SearchOption searchOption)
|
||||||
|
@ -170,18 +170,22 @@ namespace NzbDrone.Common.Disk
|
||||||
return _fileSystem.Directory.GetDirectories(path, "*", searchOption);
|
return _fileSystem.Directory.GetDirectories(path, "*", searchOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] GetFiles(string path, SearchOption searchOption)
|
public IEnumerable<string> GetFiles(string path, bool recursive)
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||||
|
|
||||||
return _fileSystem.Directory.GetFiles(path, "*.*", searchOption);
|
return _fileSystem.Directory.EnumerateFiles(path, "*", new EnumerationOptions
|
||||||
|
{
|
||||||
|
RecurseSubdirectories = recursive,
|
||||||
|
IgnoreInaccessible = true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetFolderSize(string path)
|
public long GetFolderSize(string path)
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||||
|
|
||||||
return GetFiles(path, SearchOption.AllDirectories).Sum(e => _fileSystem.FileInfo.FromFileName(e).Length);
|
return GetFiles(path, true).Sum(e => _fileSystem.FileInfo.FromFileName(e).Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetFileSize(string path)
|
public long GetFileSize(string path)
|
||||||
|
@ -302,8 +306,9 @@ namespace NzbDrone.Common.Disk
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||||
|
|
||||||
var files = _fileSystem.Directory.GetFiles(path, "*.*", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
|
var files = GetFiles(path, recursive);
|
||||||
Array.ForEach(files, RemoveReadOnly);
|
|
||||||
|
files.ToList().ForEach(RemoveReadOnly);
|
||||||
|
|
||||||
_fileSystem.Directory.Delete(path, recursive);
|
_fileSystem.Directory.Delete(path, recursive);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +409,7 @@ namespace NzbDrone.Common.Disk
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||||
|
|
||||||
foreach (var file in GetFiles(path, SearchOption.TopDirectoryOnly))
|
foreach (var file in GetFiles(path, false))
|
||||||
{
|
{
|
||||||
DeleteFile(file);
|
DeleteFile(file);
|
||||||
}
|
}
|
||||||
|
@ -504,13 +509,17 @@ namespace NzbDrone.Common.Disk
|
||||||
return _fileSystem.DirectoryInfo.FromDirectoryName(path);
|
return _fileSystem.DirectoryInfo.FromDirectoryName(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IFileInfo> GetFileInfos(string path, SearchOption searchOption = SearchOption.TopDirectoryOnly)
|
public List<IFileInfo> GetFileInfos(string path, bool recursive = false)
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||||
|
|
||||||
var di = _fileSystem.DirectoryInfo.FromDirectoryName(path);
|
var di = _fileSystem.DirectoryInfo.FromDirectoryName(path);
|
||||||
|
|
||||||
return di.GetFiles("*", searchOption).ToList();
|
return di.EnumerateFiles("*", new EnumerationOptions
|
||||||
|
{
|
||||||
|
RecurseSubdirectories = recursive,
|
||||||
|
IgnoreInaccessible = true
|
||||||
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFileInfo GetFileInfo(string path)
|
public IFileInfo GetFileInfo(string path)
|
||||||
|
|
|
@ -23,8 +23,8 @@ namespace NzbDrone.Common.Disk
|
||||||
bool FileExists(string path, StringComparison stringComparison);
|
bool FileExists(string path, StringComparison stringComparison);
|
||||||
bool FolderWritable(string path);
|
bool FolderWritable(string path);
|
||||||
bool FolderEmpty(string path);
|
bool FolderEmpty(string path);
|
||||||
string[] GetDirectories(string path);
|
IEnumerable<string> GetDirectories(string path);
|
||||||
string[] GetFiles(string path, SearchOption searchOption);
|
IEnumerable<string> GetFiles(string path, bool recursive);
|
||||||
long GetFolderSize(string path);
|
long GetFolderSize(string path);
|
||||||
long GetFileSize(string path);
|
long GetFileSize(string path);
|
||||||
void CreateFolder(string path);
|
void CreateFolder(string path);
|
||||||
|
@ -54,7 +54,7 @@ namespace NzbDrone.Common.Disk
|
||||||
IDirectoryInfo GetDirectoryInfo(string path);
|
IDirectoryInfo GetDirectoryInfo(string path);
|
||||||
List<IDirectoryInfo> GetDirectoryInfos(string path);
|
List<IDirectoryInfo> GetDirectoryInfos(string path);
|
||||||
IFileInfo GetFileInfo(string path);
|
IFileInfo GetFileInfo(string path);
|
||||||
List<IFileInfo> GetFileInfos(string path, SearchOption searchOption = SearchOption.TopDirectoryOnly);
|
List<IFileInfo> GetFileInfos(string path, bool recursive = false);
|
||||||
void RemoveEmptySubfolders(string path);
|
void RemoveEmptySubfolders(string path);
|
||||||
void SaveStream(Stream stream, string path);
|
void SaveStream(Stream stream, string path);
|
||||||
bool IsValidFolderPermissionMask(string mask);
|
bool IsValidFolderPermissionMask(string mask);
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
||||||
.Returns(new[] { targetDir });
|
.Returns(new[] { targetDir });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories))
|
.Setup(c => c.GetFiles(targetDir, true))
|
||||||
.Returns(new[] { Path.Combine(targetDir, "somefile.flac") });
|
.Returns(new[] { Path.Combine(targetDir, "somefile.flac") });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
||||||
.Returns(new[] { targetDir });
|
.Returns(new[] { targetDir });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories))
|
.Setup(c => c.GetFiles(targetDir, true))
|
||||||
.Returns(new[] { Path.Combine(targetDir, "somefile.flac") });
|
.Returns(new[] { Path.Combine(targetDir, "somefile.flac") });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
||||||
.Returns(new[] { targetDir });
|
.Returns(new[] { targetDir });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories))
|
.Setup(c => c.GetFiles(targetDir, true))
|
||||||
.Returns(new[] { Path.Combine(targetDir, "somefile.flac") });
|
.Returns(new[] { Path.Combine(targetDir, "somefile.flac") });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
|
|
@ -9,6 +9,7 @@ using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.MediaFiles.TrackImport;
|
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||||
|
@ -66,10 +67,26 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
private void GivenRootFolder(params string[] subfolders)
|
private void GivenRootFolder(params string[] subfolders)
|
||||||
{
|
{
|
||||||
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Setup(s => s.FolderExists(_rootFolder))
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Setup(s => s.GetDirectories(_rootFolder))
|
||||||
|
.Returns(subfolders);
|
||||||
|
|
||||||
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Setup(s => s.FolderEmpty(_rootFolder))
|
||||||
|
.Returns(subfolders.Empty());
|
||||||
|
|
||||||
FileSystem.AddDirectory(_rootFolder);
|
FileSystem.AddDirectory(_rootFolder);
|
||||||
|
|
||||||
foreach (var folder in subfolders)
|
foreach (var folder in subfolders)
|
||||||
{
|
{
|
||||||
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Setup(s => s.FolderExists(folder))
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
FileSystem.AddDirectory(folder);
|
FileSystem.AddDirectory(folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +96,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
GivenRootFolder(_artist.Path);
|
GivenRootFolder(_artist.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IFileInfo> GivenFiles(IEnumerable<string> files, DateTimeOffset? lastWrite = null)
|
private void GivenFiles(IEnumerable<string> files, DateTimeOffset? lastWrite = null)
|
||||||
{
|
{
|
||||||
if (lastWrite == null)
|
if (lastWrite == null)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +109,9 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
FileSystem.AddFile(file, new MockFileData(string.Empty) { LastWriteTime = lastWrite.Value });
|
FileSystem.AddFile(file, new MockFileData(string.Empty) { LastWriteTime = lastWrite.Value });
|
||||||
}
|
}
|
||||||
|
|
||||||
return files.Select(x => DiskProvider.GetFileInfo(x)).ToList();
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Setup(s => s.GetFileInfos(It.IsAny<string>(), true))
|
||||||
|
.Returns(files.Select(x => DiskProvider.GetFileInfo(x)).ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenKnownFiles(IEnumerable<string> files, DateTimeOffset? lastWrite = null)
|
private void GivenKnownFiles(IEnumerable<string> files, DateTimeOffset? lastWrite = null)
|
||||||
|
@ -139,7 +158,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(v => v.GetFiles(_artist.Path, SearchOption.AllDirectories), Times.Never());
|
.Verify(v => v.GetFiles(_artist.Path, true), Times.Never());
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileTableCleanupService>()
|
Mocker.GetMock<IMediaFileTableCleanupService>()
|
||||||
.Verify(v => v.Clean(It.IsAny<string>(), It.IsAny<List<string>>()), Times.Never());
|
.Verify(v => v.Clean(It.IsAny<string>(), It.IsAny<List<string>>()), Times.Never());
|
||||||
|
@ -194,6 +213,9 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
Subject.Scan(new List<string> { _artist.Path });
|
Subject.Scan(new List<string> { _artist.Path });
|
||||||
|
|
||||||
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Verify(v => v.GetFileInfos(It.IsAny<string>(), It.IsAny<bool>()), Times.Once());
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<IFileInfo>>(l => l.Count == 1), It.IsAny<IdentificationOverrides>(), It.IsAny<ImportDecisionMakerInfo>(), It.IsAny<ImportDecisionMakerConfig>()), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<IFileInfo>>(l => l.Count == 1), It.IsAny<IdentificationOverrides>(), It.IsAny<ImportDecisionMakerInfo>(), It.IsAny<ImportDecisionMakerConfig>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
@ -384,6 +406,8 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_insert_new_unmatched_files_when_all_new()
|
public void should_insert_new_unmatched_files_when_all_new()
|
||||||
{
|
{
|
||||||
|
GivenArtistFolder();
|
||||||
|
|
||||||
var files = new List<string>
|
var files = new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
||||||
|
@ -404,6 +428,8 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_insert_new_unmatched_files_when_some_known()
|
public void should_insert_new_unmatched_files_when_some_known()
|
||||||
{
|
{
|
||||||
|
GivenArtistFolder();
|
||||||
|
|
||||||
var files = new List<string>
|
var files = new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
||||||
|
@ -424,6 +450,8 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_insert_files_when_all_known()
|
public void should_not_insert_files_when_all_known()
|
||||||
{
|
{
|
||||||
|
GivenArtistFolder();
|
||||||
|
|
||||||
var files = new List<string>
|
var files = new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
||||||
|
@ -448,6 +476,8 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_update_info_for_unchanged_known_files()
|
public void should_not_update_info_for_unchanged_known_files()
|
||||||
{
|
{
|
||||||
|
GivenArtistFolder();
|
||||||
|
|
||||||
var files = new List<string>
|
var files = new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
||||||
|
@ -472,6 +502,8 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_update_info_for_changed_known_files()
|
public void should_update_info_for_changed_known_files()
|
||||||
{
|
{
|
||||||
|
GivenArtistFolder();
|
||||||
|
|
||||||
var files = new List<string>
|
var files = new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
Path.Combine(_artist.Path, "Season 1", "file1.flac"),
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.GetFileInfos(It.IsAny<string>(), It.IsAny<SearchOption>()))
|
.Setup(s => s.GetFileInfos(It.IsAny<string>(), It.IsAny<bool>()))
|
||||||
.Returns(new List<IFileInfo>());
|
.Returns(new List<IFileInfo>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||||
}
|
}
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.GetFileInfos(It.IsAny<string>(), SearchOption.AllDirectories))
|
.Setup(s => s.GetFileInfos(It.IsAny<string>(), true))
|
||||||
.Returns(filesToReturn);
|
.Returns(filesToReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||||
{
|
{
|
||||||
Subject.GetAudioFiles(_path);
|
Subject.GetAudioFiles(_path);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, SearchOption.AllDirectories), Times.Once());
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, true), Times.Once());
|
||||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, SearchOption.TopDirectoryOnly), Times.Never());
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, false), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -69,8 +69,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||||
{
|
{
|
||||||
Subject.GetAudioFiles(_path, true);
|
Subject.GetAudioFiles(_path, true);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, SearchOption.AllDirectories), Times.Once());
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, true), Times.Once());
|
||||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, SearchOption.TopDirectoryOnly), Times.Never());
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, false), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -78,8 +78,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||||
{
|
{
|
||||||
Subject.GetAudioFiles(_path, false);
|
Subject.GetAudioFiles(_path, false);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, SearchOption.AllDirectories), Times.Never());
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, true), Times.Never());
|
||||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, SearchOption.TopDirectoryOnly), Times.Once());
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFileInfos(_path, false), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
@ -42,7 +41,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
|
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
|
||||||
.Returns(new[] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" });
|
.Returns(new[] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(RecycleBin, SearchOption.AllDirectories))
|
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(RecycleBin, true))
|
||||||
.Returns(new[] { @"C:\Test\RecycleBin\File1.avi", @"C:\Test\RecycleBin\File2.mkv" });
|
.Returns(new[] { @"C:\Test\RecycleBin\File1.avi", @"C:\Test\RecycleBin\File2.mkv" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
@ -68,7 +67,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||||
WithRecycleBin();
|
WithRecycleBin();
|
||||||
var path = @"C:\Test\TV\30 Rock".AsOsAgnostic();
|
var path = @"C:\Test\TV\30 Rock".AsOsAgnostic();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(@"C:\Test\Recycle Bin\30 Rock".AsOsAgnostic(), SearchOption.AllDirectories))
|
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(@"C:\Test\Recycle Bin\30 Rock".AsOsAgnostic(), true))
|
||||||
.Returns(new[] { "File1", "File2", "File3" });
|
.Returns(new[] { "File1", "File2", "File3" });
|
||||||
|
|
||||||
Mocker.Resolve<RecycleBinProvider>().DeleteFolder(path);
|
Mocker.Resolve<RecycleBinProvider>().DeleteFolder(path);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System.IO;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
@ -22,7 +21,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
|
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
|
||||||
.Returns(new[] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" });
|
.Returns(new[] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(RecycleBin, SearchOption.TopDirectoryOnly))
|
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(RecycleBin, false))
|
||||||
.Returns(new[] { @"C:\Test\RecycleBin\File1.avi", @"C:\Test\RecycleBin\File2.mkv" });
|
.Returns(new[] { @"C:\Test\RecycleBin\File1.avi", @"C:\Test\RecycleBin\File2.mkv" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace NzbDrone.Core.Backup
|
||||||
// Delete journal file created during database backup
|
// Delete journal file created during database backup
|
||||||
_diskProvider.DeleteFile(Path.Combine(_backupTempFolder, "lidarr.db-journal"));
|
_diskProvider.DeleteFile(Path.Combine(_backupTempFolder, "lidarr.db-journal"));
|
||||||
|
|
||||||
_archiveService.CreateZip(backupPath, _diskProvider.GetFiles(_backupTempFolder, SearchOption.TopDirectoryOnly));
|
_archiveService.CreateZip(backupPath, _diskProvider.GetFiles(_backupTempFolder, false));
|
||||||
|
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ namespace NzbDrone.Core.Backup
|
||||||
|
|
||||||
_archiveService.Extract(backupFileName, temporaryPath);
|
_archiveService.Extract(backupFileName, temporaryPath);
|
||||||
|
|
||||||
foreach (var file in _diskProvider.GetFiles(temporaryPath, SearchOption.TopDirectoryOnly))
|
foreach (var file in _diskProvider.GetFiles(temporaryPath, false))
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(file);
|
var fileName = Path.GetFileName(file);
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ namespace NzbDrone.Core.Backup
|
||||||
|
|
||||||
private IEnumerable<string> GetBackupFiles(string path)
|
private IEnumerable<string> GetBackupFiles(string path)
|
||||||
{
|
{
|
||||||
var files = _diskProvider.GetFiles(path, SearchOption.TopDirectoryOnly);
|
var files = _diskProvider.GetFiles(path, false);
|
||||||
|
|
||||||
return files.Where(f => BackupFileRegex.IsMatch(f));
|
return files.Where(f => BackupFileRegex.IsMatch(f));
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||||
|
|
||||||
if (PreCheckWatchItemExpiry(newWatchItem, oldWatchItem))
|
if (PreCheckWatchItemExpiry(newWatchItem, oldWatchItem))
|
||||||
{
|
{
|
||||||
var files = _diskProvider.GetFiles(folder, SearchOption.AllDirectories);
|
var files = _diskProvider.GetFiles(folder, true);
|
||||||
|
|
||||||
newWatchItem.TotalSize = files.Select(_diskProvider.GetFileSize).Sum();
|
newWatchItem.TotalSize = files.Select(_diskProvider.GetFileSize).Sum();
|
||||||
newWatchItem.Hash = GetHash(folder, files);
|
newWatchItem.Hash = GetHash(folder, files);
|
||||||
|
@ -153,7 +153,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetHash(string folder, string[] files)
|
private string GetHash(string folder, IEnumerable<string> files)
|
||||||
{
|
{
|
||||||
var data = new StringBuilder();
|
var data = new StringBuilder();
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
|
||||||
|
|
||||||
public override IEnumerable<DownloadClientItem> GetItems()
|
public override IEnumerable<DownloadClientItem> GetItems()
|
||||||
{
|
{
|
||||||
foreach (var file in _diskProvider.GetFiles(Settings.StrmFolder, SearchOption.TopDirectoryOnly))
|
foreach (var file in _diskProvider.GetFiles(Settings.StrmFolder, false))
|
||||||
{
|
{
|
||||||
if (Path.GetExtension(file) != ".strm")
|
if (Path.GetExtension(file) != ".strm")
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Extras
|
||||||
var sourcePath = localTrack.Path;
|
var sourcePath = localTrack.Path;
|
||||||
var sourceFolder = _diskProvider.GetParentFolder(sourcePath);
|
var sourceFolder = _diskProvider.GetParentFolder(sourcePath);
|
||||||
var sourceFileName = Path.GetFileNameWithoutExtension(sourcePath);
|
var sourceFileName = Path.GetFileNameWithoutExtension(sourcePath);
|
||||||
var files = _diskProvider.GetFiles(sourceFolder, SearchOption.TopDirectoryOnly);
|
var files = _diskProvider.GetFiles(sourceFolder, false);
|
||||||
|
|
||||||
var wantedExtensions = _configService.ExtraFileExtensions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
var wantedExtensions = _configService.ExtraFileExtensions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
.Select(e => e.Trim(' ', '.'))
|
.Select(e => e.Trim(' ', '.'))
|
||||||
|
|
|
@ -237,8 +237,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
{
|
{
|
||||||
_logger.Debug("Scanning '{0}' for music files", path);
|
_logger.Debug("Scanning '{0}' for music files", path);
|
||||||
|
|
||||||
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
var filesOnDisk = _diskProvider.GetFileInfos(path, allDirectories);
|
||||||
var filesOnDisk = _diskProvider.GetFileInfos(path, searchOption);
|
|
||||||
|
|
||||||
var mediaFileList = filesOnDisk.Where(file => MediaFileExtensions.Extensions.Contains(file.Extension))
|
var mediaFileList = filesOnDisk.Where(file => MediaFileExtensions.Extensions.Contains(file.Extension))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -253,8 +252,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
{
|
{
|
||||||
_logger.Debug("Scanning '{0}' for non-music files", path);
|
_logger.Debug("Scanning '{0}' for non-music files", path);
|
||||||
|
|
||||||
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
var filesOnDisk = _diskProvider.GetFiles(path, allDirectories).ToList();
|
||||||
var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList();
|
|
||||||
|
|
||||||
var mediaFileList = filesOnDisk.Where(file => !MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
|
var mediaFileList = filesOnDisk.Where(file => !MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var audioFiles = _diskScanService.GetAudioFiles(directoryInfo.FullName);
|
var audioFiles = _diskScanService.GetAudioFiles(directoryInfo.FullName);
|
||||||
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f).Equals(".rar", StringComparison.OrdinalIgnoreCase));
|
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, true).Where(f => Path.GetExtension(f).Equals(".rar", StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
foreach (var audioFile in audioFiles)
|
foreach (var audioFile in audioFiles)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
@ -160,11 +159,11 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
var artist = message.Album.Artist.Value;
|
var artist = message.Album.Artist.Value;
|
||||||
var albumFolder = message.TrackFilesToDelete.FirstOrDefault()?.Path.GetParentPath();
|
var albumFolder = message.TrackFilesToDelete.FirstOrDefault()?.Path.GetParentPath();
|
||||||
|
|
||||||
if (_diskProvider.GetFiles(artist.Path, SearchOption.AllDirectories).Empty())
|
if (_diskProvider.GetFiles(artist.Path, true).Empty())
|
||||||
{
|
{
|
||||||
_diskProvider.DeleteFolder(artist.Path, true);
|
_diskProvider.DeleteFolder(artist.Path, true);
|
||||||
}
|
}
|
||||||
else if (albumFolder.IsNotNullOrWhiteSpace() && _diskProvider.GetFiles(albumFolder, SearchOption.AllDirectories).Empty())
|
else if (albumFolder.IsNotNullOrWhiteSpace() && _diskProvider.GetFiles(albumFolder, true).Empty())
|
||||||
{
|
{
|
||||||
_diskProvider.RemoveEmptySubfolders(albumFolder);
|
_diskProvider.RemoveEmptySubfolders(albumFolder);
|
||||||
}
|
}
|
||||||
|
@ -187,11 +186,11 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
var artist = message.TrackFile.Artist.Value;
|
var artist = message.TrackFile.Artist.Value;
|
||||||
var albumFolder = message.TrackFile.Path.GetParentPath();
|
var albumFolder = message.TrackFile.Path.GetParentPath();
|
||||||
|
|
||||||
if (_diskProvider.GetFiles(artist.Path, SearchOption.AllDirectories).Empty())
|
if (_diskProvider.GetFiles(artist.Path, true).Empty())
|
||||||
{
|
{
|
||||||
_diskProvider.DeleteFolder(artist.Path, true);
|
_diskProvider.DeleteFolder(artist.Path, true);
|
||||||
}
|
}
|
||||||
else if (_diskProvider.GetFiles(albumFolder, SearchOption.AllDirectories).Empty())
|
else if (_diskProvider.GetFiles(albumFolder, true).Empty())
|
||||||
{
|
{
|
||||||
_diskProvider.RemoveEmptySubfolders(albumFolder);
|
_diskProvider.RemoveEmptySubfolders(albumFolder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
|
|
||||||
_logger.Debug("Setting last accessed: {0}", path);
|
_logger.Debug("Setting last accessed: {0}", path);
|
||||||
_diskProvider.FolderSetLastWriteTime(destination, DateTime.UtcNow);
|
_diskProvider.FolderSetLastWriteTime(destination, DateTime.UtcNow);
|
||||||
foreach (var file in _diskProvider.GetFiles(destination, SearchOption.AllDirectories))
|
foreach (var file in _diskProvider.GetFiles(destination, true))
|
||||||
{
|
{
|
||||||
SetLastWriteTime(file, DateTime.UtcNow);
|
SetLastWriteTime(file, DateTime.UtcNow);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
_diskProvider.DeleteFolder(folder, true);
|
_diskProvider.DeleteFolder(folder, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var file in _diskProvider.GetFiles(_configService.RecycleBin, SearchOption.TopDirectoryOnly))
|
foreach (var file in _diskProvider.GetFiles(_configService.RecycleBin, false))
|
||||||
{
|
{
|
||||||
_diskProvider.DeleteFile(file);
|
_diskProvider.DeleteFile(file);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
|
|
||||||
_logger.Info("Removing items older than {0} days from the recycling bin", cleanupDays);
|
_logger.Info("Removing items older than {0} days from the recycling bin", cleanupDays);
|
||||||
|
|
||||||
foreach (var file in _diskProvider.GetFiles(_configService.RecycleBin, SearchOption.AllDirectories))
|
foreach (var file in _diskProvider.GetFiles(_configService.RecycleBin, true))
|
||||||
{
|
{
|
||||||
if (_diskProvider.FileGetLastWrite(file).AddDays(cleanupDays) > DateTime.UtcNow)
|
if (_diskProvider.FileGetLastWrite(file).AddDays(cleanupDays) > DateTime.UtcNow)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.EnsureThat;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.TPL;
|
using NzbDrone.Common.TPL;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -25,7 +25,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
||||||
.Setup(c => c.FolderExists("/System/Library/CoreServices/")).Returns(true);
|
.Setup(c => c.FolderExists("/System/Library/CoreServices/")).Returns(true);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.GetFiles("/System/Library/CoreServices/", SearchOption.TopDirectoryOnly))
|
.Setup(c => c.GetFiles("/System/Library/CoreServices/", false))
|
||||||
.Returns(new[] { plistPath });
|
.Returns(new[] { plistPath });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
@ -49,7 +49,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
||||||
.Setup(c => c.FolderExists("/System/Library/CoreServices/")).Returns(true);
|
.Setup(c => c.FolderExists("/System/Library/CoreServices/")).Returns(true);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.GetFiles("/System/Library/CoreServices/", SearchOption.TopDirectoryOnly))
|
.Setup(c => c.GetFiles("/System/Library/CoreServices/", false))
|
||||||
.Returns(new[] { plistPath });
|
.Returns(new[] { plistPath });
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
@ -69,7 +69,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
||||||
Subject.Read().Should().BeNull();
|
Subject.Read().Should().BeNull();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(c => c.GetFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly), Times.Never());
|
.Verify(c => c.GetFiles(It.IsAny<string>(), false), Times.Never());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,25 +30,25 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_null_if_etc_doestn_exist()
|
public void should_return_null_if_etc_doesnt_exist()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists("/etc/")).Returns(false);
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists("/etc/")).Returns(false);
|
||||||
Subject.Read().Should().BeNull();
|
Subject.Read().Should().BeNull();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(c => c.GetFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly), Times.Never());
|
.Verify(c => c.GetFiles(It.IsAny<string>(), false), Times.Never());
|
||||||
|
|
||||||
Subject.Read().Should().BeNull();
|
Subject.Read().Should().BeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_null_if_release_file_doestn_exist()
|
public void should_return_null_if_release_file_doesnt_exist()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists("/etc/")).Returns(true);
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists("/etc/")).Returns(true);
|
||||||
Subject.Read().Should().BeNull();
|
Subject.Read().Should().BeNull();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.GetFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly)).Returns(System.Array.Empty<string>());
|
.Setup(c => c.GetFiles(It.IsAny<string>(), false)).Returns(System.Array.Empty<string>());
|
||||||
|
|
||||||
Subject.Read().Should().BeNull();
|
Subject.Read().Should().BeNull();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
||||||
Subject.Read().Should().BeNull();
|
Subject.Read().Should().BeNull();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.GetFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly)).Returns(new[]
|
.Setup(c => c.GetFiles(It.IsAny<string>(), false)).Returns(new[]
|
||||||
{
|
{
|
||||||
"/etc/lsb-release",
|
"/etc/lsb-release",
|
||||||
"/etc/os-release"
|
"/etc/os-release"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
@ -21,7 +20,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var issueFile = _diskProvider.GetFiles("/etc/", SearchOption.TopDirectoryOnly).SingleOrDefault(c => c.EndsWith("/issue"));
|
var issueFile = _diskProvider.GetFiles("/etc/", false).SingleOrDefault(c => c.EndsWith("/issue"));
|
||||||
|
|
||||||
if (issueFile == null)
|
if (issueFile == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
@ -34,7 +33,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var allFiles = _diskProvider.GetFiles(PLIST_DIR, SearchOption.TopDirectoryOnly);
|
var allFiles = _diskProvider.GetFiles(PLIST_DIR, false);
|
||||||
|
|
||||||
var versionFile = allFiles.SingleOrDefault(c =>
|
var versionFile = allFiles.SingleOrDefault(c =>
|
||||||
c.EndsWith("/SystemVersion.plist") ||
|
c.EndsWith("/SystemVersion.plist") ||
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
@ -22,7 +21,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var releaseFiles = _diskProvider.GetFiles("/etc/", SearchOption.TopDirectoryOnly).Where(c => c.EndsWith("release")).ToList();
|
var releaseFiles = _diskProvider.GetFiles("/etc/", false).Where(c => c.EndsWith("release")).ToList();
|
||||||
|
|
||||||
var name = "Linux";
|
var name = "Linux";
|
||||||
var fullName = "";
|
var fullName = "";
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
@ -24,7 +23,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var versionFile = _diskProvider.GetFiles("/etc.defaults/", SearchOption.TopDirectoryOnly).SingleOrDefault(c => c.EndsWith("VERSION"));
|
var versionFile = _diskProvider.GetFiles("/etc.defaults/", false).SingleOrDefault(c => c.EndsWith("VERSION"));
|
||||||
|
|
||||||
if (versionFile == null)
|
if (versionFile == null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue