parent
60714eb89a
commit
e5aa858410
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Core;
|
||||
using ICSharpCode.SharpZipLib.GZip;
|
||||
|
@ -11,7 +12,7 @@ namespace NzbDrone.Common
|
|||
public interface IArchiveService
|
||||
{
|
||||
void Extract(string compressedFile, string destination);
|
||||
void CreateZip(string path, params string[] files);
|
||||
void CreateZip(string path, IEnumerable<string> files);
|
||||
}
|
||||
|
||||
public class ArchiveService : IArchiveService
|
||||
|
@ -39,7 +40,7 @@ namespace NzbDrone.Common
|
|||
_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))
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace NzbDrone.Common.Disk
|
|||
{
|
||||
CheckFolderExists(path);
|
||||
|
||||
var dirFiles = GetFiles(path, SearchOption.AllDirectories).ToList();
|
||||
var dirFiles = GetFiles(path, true).ToList();
|
||||
|
||||
if (!dirFiles.Any())
|
||||
{
|
||||
|
@ -149,25 +149,29 @@ namespace NzbDrone.Common.Disk
|
|||
return Directory.EnumerateFileSystemEntries(path).Empty();
|
||||
}
|
||||
|
||||
public string[] GetDirectories(string path)
|
||||
public IEnumerable<string> GetDirectories(string path)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||
|
||||
return Directory.GetDirectories(path);
|
||||
return Directory.EnumerateDirectories(path);
|
||||
}
|
||||
|
||||
public string[] GetFiles(string path, SearchOption searchOption)
|
||||
public IEnumerable<string> GetFiles(string path, bool recursive)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||
|
||||
return Directory.GetFiles(path, "*.*", searchOption);
|
||||
return Directory.EnumerateFiles(path, "*", new EnumerationOptions
|
||||
{
|
||||
RecurseSubdirectories = recursive,
|
||||
IgnoreInaccessible = true
|
||||
});
|
||||
}
|
||||
|
||||
public long GetFolderSize(string path)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||
|
||||
return GetFiles(path, SearchOption.AllDirectories).Sum(e => new FileInfo(e).Length);
|
||||
return GetFiles(path, true).Sum(e => new FileInfo(e).Length);
|
||||
}
|
||||
|
||||
public long GetFileSize(string path)
|
||||
|
@ -288,8 +292,9 @@ namespace NzbDrone.Common.Disk
|
|||
{
|
||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||
|
||||
var files = Directory.GetFiles(path, "*.*", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
|
||||
Array.ForEach(files, RemoveReadOnly);
|
||||
var files = GetFiles(path, recursive);
|
||||
|
||||
files.ToList().ForEach(RemoveReadOnly);
|
||||
|
||||
Directory.Delete(path, recursive);
|
||||
}
|
||||
|
@ -381,7 +386,7 @@ namespace NzbDrone.Common.Disk
|
|||
{
|
||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||
|
||||
foreach (var file in GetFiles(path, SearchOption.TopDirectoryOnly))
|
||||
foreach (var file in GetFiles(path, false))
|
||||
{
|
||||
DeleteFile(file);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace NzbDrone.Common.Disk
|
|||
bool FileExists(string path, StringComparison stringComparison);
|
||||
bool FolderWritable(string path);
|
||||
bool FolderEmpty(string path);
|
||||
string[] GetDirectories(string path);
|
||||
string[] GetFiles(string path, SearchOption searchOption);
|
||||
IEnumerable<string> GetDirectories(string path);
|
||||
IEnumerable<string> GetFiles(string path, bool recursive);
|
||||
long GetFolderSize(string path);
|
||||
long GetFileSize(string path);
|
||||
void CreateFolder(string path);
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
.Returns(new[] { targetDir });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories))
|
||||
.Setup(c => c.GetFiles(targetDir, true))
|
||||
.Returns(new[] { Path.Combine(targetDir, "somefile.mkv") });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
.Returns(new[] { targetDir });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories))
|
||||
.Setup(c => c.GetFiles(targetDir, true))
|
||||
.Returns(new[] { Path.Combine(targetDir, "somefile.mkv") });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
.Returns(new[] { targetDir });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories))
|
||||
.Setup(c => c.GetFiles(targetDir, true))
|
||||
.Returns(new[] { Path.Combine(targetDir, "somefile.mkv") });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace NzbDrone.Core.Test.Extras
|
|||
WithExistingFile(file);
|
||||
}
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(_episodeFolder, It.IsAny<SearchOption>()))
|
||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(_episodeFolder, It.IsAny<bool>()))
|
||||
.Returns(files.ToArray());
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,8 @@ namespace NzbDrone.Core.Test.Extras
|
|||
|
||||
Subject.ImportEpisode(_localEpisode, _episodeFile, true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Verify(v => v.GetFiles(_episodeFolder, SearchOption.AllDirectories), Times.Once);
|
||||
Mocker.GetMock<IDiskProvider>().Verify(v => v.GetFiles(_episodeFolder, SearchOption.TopDirectoryOnly), Times.Never);
|
||||
Mocker.GetMock<IDiskProvider>().Verify(v => v.GetFiles(_episodeFolder, true), Times.Once);
|
||||
Mocker.GetMock<IDiskProvider>().Verify(v => v.GetFiles(_episodeFolder, false), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -245,8 +245,8 @@ namespace NzbDrone.Core.Test.Extras
|
|||
|
||||
Subject.ImportEpisode(_localEpisode, _episodeFile, true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Verify(v => v.GetFiles(_episodeFolder, SearchOption.AllDirectories), Times.Never);
|
||||
Mocker.GetMock<IDiskProvider>().Verify(v => v.GetFiles(_episodeFolder, SearchOption.TopDirectoryOnly), Times.Once);
|
||||
Mocker.GetMock<IDiskProvider>().Verify(v => v.GetFiles(_episodeFolder, true), Times.Never);
|
||||
Mocker.GetMock<IDiskProvider>().Verify(v => v.GetFiles(_episodeFolder, false), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
|
|||
sampleFile
|
||||
};
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(It.IsAny<string>(), true))
|
||||
.Returns(videoFiles);
|
||||
|
||||
Mocker.GetMock<IDetectSample>().Setup(s => s.IsSample(It.IsAny<Series>(), sampleFile, It.IsAny<bool>()))
|
||||
|
@ -198,7 +198,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
|
|||
Path.Combine(_series.Path, "Season 1", "Series Title - S01E01.sample.mkv").AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetFiles(It.IsAny<string>(), true))
|
||||
.Returns(videoFiles);
|
||||
|
||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, new List<string> { subtitleFile }, true).ToList();
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
private void GivenFiles(IEnumerable<string> files)
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), true))
|
||||
.Returns(files.ToArray());
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.GetFiles(_series.Path, SearchOption.AllDirectories), Times.Never());
|
||||
.Verify(v => v.GetFiles(_series.Path, true), Times.Never());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.CreateFolder(_series.Path), Times.Never());
|
||||
|
@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.GetFiles(_series.Path, SearchOption.AllDirectories), Times.Never());
|
||||
.Verify(v => v.GetFiles(_series.Path, true), Times.Never());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.CreateFolder(_series.Path), Times.Never());
|
||||
|
@ -267,7 +267,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
Subject.Scan(_series);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.GetFiles(It.IsAny<string>(), It.IsAny<SearchOption>()), Times.Once());
|
||||
.Verify(v => v.GetFiles(It.IsAny<string>(), It.IsAny<bool>()), Times.Once());
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series, false), Times.Once());
|
||||
|
|
|
@ -284,7 +284,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Returns(DetectSampleResult.Sample);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), true))
|
||||
.Returns(new[] { _videoFiles.First().Replace(".ext", ".rar") });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -310,7 +310,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(folderName))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFiles(folderName, SearchOption.TopDirectoryOnly))
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFiles(folderName, false))
|
||||
.Returns(new[] { fileName });
|
||||
|
||||
var localEpisode = new LocalEpisode();
|
||||
|
@ -463,7 +463,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Returns(imported.Select(i => new ImportResult(i)).ToList());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), true))
|
||||
.Returns(new[] { _videoFiles.First().Replace(".ext", ".rar") });
|
||||
|
||||
var result = Subject.ProcessPath(path);
|
||||
|
@ -489,7 +489,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Returns(imported.Select(i => new ImportResult(i)).ToList());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), true))
|
||||
.Returns(new[] { _videoFiles.First().Replace(".ext", ".exe") });
|
||||
|
||||
var result = Subject.ProcessPath(path);
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
{
|
||||
var filesToReturn = files.ToArray();
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), true))
|
||||
.Returns(filesToReturn);
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
|
||||
Subject.GetVideoFiles(path);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, true), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, false), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -59,8 +59,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
|
||||
Subject.GetVideoFiles(path, true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, true), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, false), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -70,8 +70,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
|
||||
Subject.GetVideoFiles(path, false);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, true), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, false), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
@ -42,7 +41,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
|||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
|
||||
.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" });
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
@ -68,7 +67,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
|||
WithRecycleBin();
|
||||
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" });
|
||||
|
||||
Mocker.Resolve<RecycleBinProvider>().DeleteFolder(path);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.IO;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
@ -22,7 +21,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
|||
Mocker.GetMock<IDiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
|
||||
.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" });
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace NzbDrone.Core.Backup
|
|||
// Delete journal file created during database backup
|
||||
_diskProvider.DeleteFile(Path.Combine(_backupTempFolder, "sonarr.db-journal"));
|
||||
|
||||
_archiveService.CreateZip(backupPath, _diskProvider.GetFiles(_backupTempFolder, SearchOption.TopDirectoryOnly));
|
||||
_archiveService.CreateZip(backupPath, _diskProvider.GetFiles(_backupTempFolder, false));
|
||||
|
||||
_logger.ProgressDebug("Backup zip created");
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ namespace NzbDrone.Core.Backup
|
|||
|
||||
_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);
|
||||
|
||||
|
@ -238,7 +238,7 @@ namespace NzbDrone.Core.Backup
|
|||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -69,7 +69,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
|||
|
||||
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.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();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using FluentValidation.Results;
|
||||
|
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
|
|||
|
||||
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")
|
||||
{
|
||||
|
|
|
@ -60,9 +60,7 @@ namespace NzbDrone.Core.Extras
|
|||
return;
|
||||
}
|
||||
|
||||
var folderSearchOption = localEpisode.FolderEpisodeInfo == null
|
||||
? SearchOption.TopDirectoryOnly
|
||||
: SearchOption.AllDirectories;
|
||||
var folderSearchOption = localEpisode.FolderEpisodeInfo != null;
|
||||
|
||||
var wantedExtensions = _configService.ExtraFileExtensions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(e => e.Trim(' ', '.')
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace NzbDrone.Core.Extras.Subtitles
|
|||
// Use any sub if only episode in folder
|
||||
if (matchingFiles.Count == 0 && filteredFiles.Count > 0)
|
||||
{
|
||||
var videoFiles = _diskProvider.GetFiles(sourceFolder, SearchOption.AllDirectories)
|
||||
var videoFiles = _diskProvider.GetFiles(sourceFolder, true)
|
||||
.Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
|
||||
.ToList();
|
||||
|
||||
|
|
|
@ -194,8 +194,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
{
|
||||
_logger.Debug("Scanning '{0}' for video files", path);
|
||||
|
||||
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||
var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList();
|
||||
var filesOnDisk = _diskProvider.GetFiles(path, allDirectories).ToList();
|
||||
|
||||
var mediaFileList = filesOnDisk.Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
|
||||
.ToList();
|
||||
|
@ -210,8 +209,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
{
|
||||
_logger.Debug("Scanning '{0}' for non-video files", path);
|
||||
|
||||
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||
var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList();
|
||||
var filesOnDisk = _diskProvider.GetFiles(path, allDirectories).ToList();
|
||||
|
||||
var mediaFileList = filesOnDisk.Where(file => !MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
|
||||
.ToList();
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
try
|
||||
{
|
||||
var videoFiles = _diskScanService.GetVideoFiles(directoryInfo.FullName);
|
||||
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f =>
|
||||
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, true).Where(f =>
|
||||
Path.GetExtension(f).Equals(".rar",
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
|
@ -309,7 +309,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
private ImportResult CheckEmptyResultForIssue(string folder)
|
||||
{
|
||||
var files = _diskProvider.GetFiles(folder, SearchOption.AllDirectories);
|
||||
var files = _diskProvider.GetFiles(folder, true);
|
||||
|
||||
if (files.Any(file => FileExtensions.ExecutableExtensions.Contains(Path.GetExtension(file))))
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
_logger.Debug("Setting last accessed: {0}", path);
|
||||
_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);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
_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);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
_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)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.IO;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -25,7 +25,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
|||
.Setup(c => c.FolderExists("/System/Library/CoreServices/")).Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.GetFiles("/System/Library/CoreServices/", SearchOption.TopDirectoryOnly))
|
||||
.Setup(c => c.GetFiles("/System/Library/CoreServices/", false))
|
||||
.Returns(new[] { plistPath });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -49,7 +49,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
|||
.Setup(c => c.FolderExists("/System/Library/CoreServices/")).Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.GetFiles("/System/Library/CoreServices/", SearchOption.TopDirectoryOnly))
|
||||
.Setup(c => c.GetFiles("/System/Library/CoreServices/", false))
|
||||
.Returns(new[] { plistPath });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -69,7 +69,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
|||
Subject.Read().Should().BeNull();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.GetFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly), Times.Never());
|
||||
.Verify(c => c.GetFiles(It.IsAny<string>(), false), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
@ -29,25 +29,25 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
|||
}
|
||||
|
||||
[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);
|
||||
Subject.Read().Should().BeNull();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
[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);
|
||||
Subject.Read().Should().BeNull();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.GetFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly)).Returns(Array.Empty<string>());
|
||||
.Setup(c => c.GetFiles(It.IsAny<string>(), false)).Returns(Array.Empty<string>());
|
||||
|
||||
Subject.Read().Should().BeNull();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
|
|||
Subject.Read().Should().BeNull();
|
||||
|
||||
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/os-release"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
@ -21,7 +20,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
|
@ -33,7 +32,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
|||
return null;
|
||||
}
|
||||
|
||||
var allFiles = _diskProvider.GetFiles(PLIST_DIR, SearchOption.TopDirectoryOnly);
|
||||
var allFiles = _diskProvider.GetFiles(PLIST_DIR, false);
|
||||
|
||||
var versionFile = allFiles.SingleOrDefault(c =>
|
||||
c.EndsWith("/SystemVersion.plist") ||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
@ -22,7 +21,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
|||
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 fullName = "";
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
@ -24,7 +23,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Sonarr.Api.V3.Logs
|
|||
|
||||
protected override IEnumerable<string> GetLogFiles()
|
||||
{
|
||||
return _diskProvider.GetFiles(_appFolderInfo.GetLogFolder(), SearchOption.TopDirectoryOnly);
|
||||
return _diskProvider.GetFiles(_appFolderInfo.GetLogFolder(), false);
|
||||
}
|
||||
|
||||
protected override string GetLogFilePath(string filename)
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Sonarr.Api.V3.Logs
|
|||
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))
|
||||
.ToList();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue