diff --git a/NzbDrone.Api/Client/ClientSettings.cs b/NzbDrone.Api/Client/ClientSettings.cs index 872cd1fd0..753df22a6 100644 --- a/NzbDrone.Api/Client/ClientSettings.cs +++ b/NzbDrone.Api/Client/ClientSettings.cs @@ -14,21 +14,21 @@ namespace NzbDrone.Api.Client { public class ClientSettings : IHandle { - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; private static readonly Regex VersionRegex = new Regex(@"(?<=Version:\s')(.*)(?=')", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex BuildDateRegex = new Regex(@"(?<=BuildDate:\s)('.*')", RegexOptions.IgnoreCase | RegexOptions.Compiled); - public ClientSettings(IAppDirectoryInfo appDirectoryInfo) + public ClientSettings(IAppFolderInfo appFolderInfo) { - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; } public void Handle(ApplicationStartedEvent message) { //TODO: Update the APIKey (when we have it) - var appFile = Path.Combine(_appDirectoryInfo.StartUpPath, "UI", "app.js"); + var appFile = Path.Combine(_appFolderInfo.StartUpFolder, "UI", "app.js"); var contents = File.ReadAllText(appFile); var version = BuildInfo.Version; var date = BuildInfo.BuildDateTime; diff --git a/NzbDrone.Api/Frontend/IndexModule.cs b/NzbDrone.Api/Frontend/IndexModule.cs index 2ae21ff4d..46eac2824 100644 --- a/NzbDrone.Api/Frontend/IndexModule.cs +++ b/NzbDrone.Api/Frontend/IndexModule.cs @@ -16,11 +16,11 @@ namespace NzbDrone.Api.Frontend private readonly string _indexPath; - public IndexModule(IDiskProvider diskProvider, ICacheManger cacheManger, IAppDirectoryInfo appDirectory) + public IndexModule(IDiskProvider diskProvider, ICacheManger cacheManger, IAppFolderInfo appFolder) { _diskProvider = diskProvider; - _indexPath = Path.Combine(appDirectory.StartUpPath, "UI", "index.html"); + _indexPath = Path.Combine(appFolder.StartUpFolder, "UI", "index.html"); _indexCache = cacheManger.GetCache(typeof(IndexModule)); //Serve anything that doesn't have an extension diff --git a/NzbDrone.Api/Frontend/MediaCoverMapper.cs b/NzbDrone.Api/Frontend/MediaCoverMapper.cs index fe74862fe..0a626ead1 100644 --- a/NzbDrone.Api/Frontend/MediaCoverMapper.cs +++ b/NzbDrone.Api/Frontend/MediaCoverMapper.cs @@ -6,11 +6,11 @@ namespace NzbDrone.Api.Frontend { public class MediaCoverMapper : IMapHttpRequestsToDisk { - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; - public MediaCoverMapper(IAppDirectoryInfo appDirectoryInfo) + public MediaCoverMapper(IAppFolderInfo appFolderInfo) { - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; } public string Map(string resourceUrl) @@ -18,7 +18,7 @@ namespace NzbDrone.Api.Frontend var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar); path = path.Trim(Path.DirectorySeparatorChar).ToLower(); - return Path.Combine(_appDirectoryInfo.GetAppDataPath(), path); + return Path.Combine(_appFolderInfo.GetAppDataPath(), path); } public bool CanHandle(string resourceUrl) diff --git a/NzbDrone.Api/Frontend/StaticResourceMapper.cs b/NzbDrone.Api/Frontend/StaticResourceMapper.cs index c178fe696..86353f447 100644 --- a/NzbDrone.Api/Frontend/StaticResourceMapper.cs +++ b/NzbDrone.Api/Frontend/StaticResourceMapper.cs @@ -7,7 +7,7 @@ namespace NzbDrone.Api.Frontend { public class StaticResourceMapper : IMapHttpRequestsToDisk { - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; private static readonly string[] Extensions = new[] { ".css", ".js", @@ -24,9 +24,9 @@ namespace NzbDrone.Api.Frontend ".eot" }; - public StaticResourceMapper(IAppDirectoryInfo appDirectoryInfo) + public StaticResourceMapper(IAppFolderInfo appFolderInfo) { - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; } public string Map(string resourceUrl) @@ -35,7 +35,7 @@ namespace NzbDrone.Api.Frontend path = path.Trim(Path.DirectorySeparatorChar).ToLower(); - return Path.Combine(_appDirectoryInfo.StartUpPath, "ui", path); + return Path.Combine(_appFolderInfo.StartUpFolder, "ui", path); } public bool CanHandle(string resourceUrl) diff --git a/NzbDrone.Api/System/SystemModule.cs b/NzbDrone.Api/System/SystemModule.cs index b4f2e714d..b8e90262b 100644 --- a/NzbDrone.Api/System/SystemModule.cs +++ b/NzbDrone.Api/System/SystemModule.cs @@ -8,14 +8,14 @@ namespace NzbDrone.Api.System { public class SystemModule : NzbDroneApiModule { - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; private readonly IRuntimeInfo _runtimeInfo; private readonly IRouteCacheProvider _routeCacheProvider; - public SystemModule(IAppDirectoryInfo appDirectoryInfo, IRuntimeInfo runtimeInfo, IRouteCacheProvider routeCacheProvider) + public SystemModule(IAppFolderInfo appFolderInfo, IRuntimeInfo runtimeInfo, IRouteCacheProvider routeCacheProvider) : base("system") { - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; _runtimeInfo = runtimeInfo; _routeCacheProvider = routeCacheProvider; Get["/status"] = x => GetStatus(); @@ -32,8 +32,8 @@ namespace NzbDrone.Api.System IsProduction = RuntimeInfo.IsProduction, IsAdmin = _runtimeInfo.IsAdmin, IsUserInteractive = _runtimeInfo.IsUserInteractive, - StartupPath = _appDirectoryInfo.StartUpPath, - AppData = _appDirectoryInfo.GetAppDataPath(), + StartupPath = _appFolderInfo.StartUpFolder, + AppData = _appFolderInfo.GetAppDataPath(), OsVersion = OsInfo.Version.ToString(), IsMono = OsInfo.IsMono, IsLinux = OsInfo.IsLinux, diff --git a/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/NzbDrone.Common.Test/ConfigFileProviderTest.cs index bf2ee4bd5..9ee37246f 100644 --- a/NzbDrone.Common.Test/ConfigFileProviderTest.cs +++ b/NzbDrone.Common.Test/ConfigFileProviderTest.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Common.Test { WithTempAsAppPath(); - var configFile = Mocker.Resolve().GetConfigPath(); + var configFile = Mocker.Resolve().GetConfigPath(); if (File.Exists(configFile)) File.Delete(configFile); diff --git a/NzbDrone.Common.Test/DiskProviderFixture.cs b/NzbDrone.Common.Test/DiskProviderFixture.cs index a76b017e4..0b95d93b7 100644 --- a/NzbDrone.Common.Test/DiskProviderFixture.cs +++ b/NzbDrone.Common.Test/DiskProviderFixture.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Common.Test public void moveFile_should_overwrite_existing_file() { - Subject.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName); + Subject.CopyFolder(_binFolder.FullName, _binFolderCopy.FullName); var targetPath = Path.Combine(_binFolderCopy.FullName, "file.move"); @@ -69,7 +69,7 @@ namespace NzbDrone.Common.Test public void moveFile_should_not_move_overwrite_itself() { - Subject.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName); + Subject.CopyFolder(_binFolder.FullName, _binFolderCopy.FullName); var targetPath = _binFolderCopy.GetFiles("*.dll", SearchOption.AllDirectories).First().FullName; @@ -84,7 +84,7 @@ namespace NzbDrone.Common.Test { - Subject.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName); + Subject.CopyFolder(_binFolder.FullName, _binFolderCopy.FullName); VerifyCopy(); @@ -97,13 +97,13 @@ namespace NzbDrone.Common.Test - Subject.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName); + Subject.CopyFolder(_binFolder.FullName, _binFolderCopy.FullName); //Delete Random File _binFolderCopy.Refresh(); _binFolderCopy.GetFiles("*.*", SearchOption.AllDirectories).First().Delete(); - Subject.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName); + Subject.CopyFolder(_binFolder.FullName, _binFolderCopy.FullName); VerifyCopy(); @@ -114,12 +114,12 @@ namespace NzbDrone.Common.Test { - Subject.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName); - Subject.CopyDirectory(_binFolder.FullName, _binFolderMove.FullName); + Subject.CopyFolder(_binFolder.FullName, _binFolderCopy.FullName); + Subject.CopyFolder(_binFolder.FullName, _binFolderMove.FullName); VerifyCopy(); - Subject.MoveDirectory(_binFolderCopy.FullName, _binFolderMove.FullName); + Subject.MoveFolder(_binFolderCopy.FullName, _binFolderMove.FullName); VerifyMove(); @@ -166,11 +166,11 @@ namespace NzbDrone.Common.Test [Test] public void folder_should_return_correct_value_for_last_write() { - var appPath = new AppDirectoryInfo().WorkingDirectory; + var appPath = new AppFolderInfo(Subject).AppDataFolder; TestLogger.Info("Path is: {0}", appPath); - Subject.WriteAllText(Path.Combine(appPath,"newfile.txt"), ""); + Subject.WriteAllText(Path.Combine(appPath, "newfile.txt"), ""); Subject.GetLastFolderWrite(appPath).Should().BeOnOrAfter(DateTime.UtcNow.AddMinutes(-10)); Subject.GetLastFolderWrite(appPath).Should().BeBefore(DateTime.UtcNow); @@ -184,18 +184,6 @@ namespace NzbDrone.Common.Test Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc); } - [Test] - public void IsChildOfPath_should_return_true_when_it_is_a_child() - { - Subject.IsChildOfPath(@"C:\Test\TV", @"C:\Test").Should().BeTrue(); - } - - [Test] - public void IsChildOfPath_should_return_false_when_it_is_not_a_child() - { - Subject.IsChildOfPath(@"C:\NOT_Test\TV", @"C:\Test").Should().BeFalse(); - } - private void VerifyCopy() { _binFolder.Refresh(); diff --git a/NzbDrone.Common.Test/EnviromentProviderTest.cs b/NzbDrone.Common.Test/EnviromentProviderTest.cs index 34c5688ae..c927030d2 100644 --- a/NzbDrone.Common.Test/EnviromentProviderTest.cs +++ b/NzbDrone.Common.Test/EnviromentProviderTest.cs @@ -7,22 +7,22 @@ using NzbDrone.Test.Common; namespace NzbDrone.Common.Test { [TestFixture] - public class IAppDirectoryInfoTest : TestBase + public class IAppDirectoryInfoTest : TestBase { [Test] public void StartupPath_should_not_be_empty() { - Subject.StartUpPath.Should().NotBeBlank(); - Path.IsPathRooted(Subject.StartUpPath).Should().BeTrue("Path is not rooted"); + Subject.StartUpFolder.Should().NotBeBlank(); + Path.IsPathRooted(Subject.StartUpFolder).Should().BeTrue("Path is not rooted"); } [Test] public void ApplicationPath_should_not_be_empty() { - Subject.WorkingDirectory.Should().NotBeBlank(); - Path.IsPathRooted(Subject.WorkingDirectory).Should().BeTrue("Path is not rooted"); + Subject.AppDataFolder.Should().NotBeBlank(); + Path.IsPathRooted(Subject.AppDataFolder).Should().BeTrue("Path is not rooted"); } diff --git a/NzbDrone.Common.Test/PathExtensionFixture.cs b/NzbDrone.Common.Test/PathExtensionFixture.cs index 2f1110b4b..65b20b24d 100644 --- a/NzbDrone.Common.Test/PathExtensionFixture.cs +++ b/NzbDrone.Common.Test/PathExtensionFixture.cs @@ -12,13 +12,13 @@ namespace NzbDrone.Common.Test public class PathExtensionFixture : TestBase { - private IAppDirectoryInfo GetIAppDirectoryInfo() + private IAppFolderInfo GetIAppDirectoryInfo() { - var fakeEnvironment = new Mock(); + var fakeEnvironment = new Mock(); - fakeEnvironment.SetupGet(c => c.WorkingDirectory).Returns(@"C:\NzbDrone\"); + fakeEnvironment.SetupGet(c => c.AppDataFolder).Returns(@"C:\NzbDrone\"); - fakeEnvironment.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\"); + fakeEnvironment.SetupGet(c => c.TempFolder).Returns(@"C:\Temp\"); return fakeEnvironment.Object; } diff --git a/NzbDrone.Common/EnvironmentInfo/AppDirectoryInfo.cs b/NzbDrone.Common/EnvironmentInfo/AppDirectoryInfo.cs deleted file mode 100644 index d463be5a2..000000000 --- a/NzbDrone.Common/EnvironmentInfo/AppDirectoryInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.IO; -using System.Reflection; - -namespace NzbDrone.Common.EnvironmentInfo -{ - public interface IAppDirectoryInfo - { - string WorkingDirectory { get; } - string SystemTemp { get; } - string StartUpPath { get; } - } - - public class AppDirectoryInfo : IAppDirectoryInfo - { - - public AppDirectoryInfo() - { - WorkingDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create), "NzbDrone"); - StartUpPath = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName; - SystemTemp = Path.GetTempPath(); - - if (!Directory.Exists(WorkingDirectory)) - { - Directory.CreateDirectory(WorkingDirectory); - } - } - - public string WorkingDirectory { get; private set; } - - public string StartUpPath { get; private set; } - - public String SystemTemp { get; private set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs b/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs new file mode 100644 index 000000000..b4e708af7 --- /dev/null +++ b/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs @@ -0,0 +1,52 @@ +using System; +using System.IO; +using System.Reflection; + +namespace NzbDrone.Common.EnvironmentInfo +{ + public interface IAppFolderInfo + { + string AppDataFolder { get; } + string TempFolder { get; } + string StartUpFolder { get; } + } + + public class AppFolderInfo : IAppFolderInfo + { + private readonly IDiskProvider _diskProvider; + + public AppFolderInfo(IDiskProvider diskProvider) + { + _diskProvider = diskProvider; + AppDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData, Environment.SpecialFolderOption.DoNotVerify), "NzbDrone"); + StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName; + TempFolder = Path.GetTempPath(); + + if (!_diskProvider.FolderExists(AppDataFolder)) + { + MigrateFromAppDate(); + } + } + + + private void MigrateFromAppDate() + { + var oldAppDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify), "NzbDrone"); + + if (_diskProvider.FolderExists(oldAppDataFolder)) + { + _diskProvider.MoveFolder(oldAppDataFolder, AppDataFolder); + } + else + { + _diskProvider.CreateFolder(AppDataFolder); + } + } + + public string AppDataFolder { get; private set; } + + public string StartUpFolder { get; private set; } + + public String TempFolder { get; private set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Common/IDiskProvider.cs b/NzbDrone.Common/IDiskProvider.cs index 6d0dc327d..5cf1b3783 100644 --- a/NzbDrone.Common/IDiskProvider.cs +++ b/NzbDrone.Common/IDiskProvider.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices; @@ -18,25 +17,21 @@ namespace NzbDrone.Common bool FileExists(string path); string[] GetDirectories(string path); string[] GetFiles(string path, SearchOption searchOption); - long GetDirectorySize(string path); + long GetFolderSize(string path); long GetFileSize(string path); String CreateFolder(string path); - void CopyDirectory(string source, string target); - void MoveDirectory(string source, string destination); + void CopyFolder(string source, string target); + void MoveFolder(string source, string destination); void DeleteFile(string path); void MoveFile(string source, string destination); void DeleteFolder(string path, bool recursive); - DateTime DirectoryDateCreated(string path); - IEnumerable GetFileInfos(string path, string pattern, SearchOption searchOption); void InheritFolderPermissions(string filename); long GetAvilableSpace(string path); string ReadAllText(string filePath); void WriteAllText(string filename, string contents); void FileSetLastWriteTimeUtc(string path, DateTime dateTime); - void DirectorySetLastWriteTimeUtc(string path, DateTime dateTime); - bool IsFolderLocked(string path); + void FolderSetLastWriteTimeUtc(string path, DateTime dateTime); bool IsFileLocked(FileInfo file); - bool IsChildOfPath(string child, string parent); string GetPathRoot(string path); } @@ -125,7 +120,7 @@ namespace NzbDrone.Common return Directory.GetFiles(path, "*.*", searchOption); } - public virtual long GetDirectorySize(string path) + public virtual long GetFolderSize(string path) { Ensure.That(() => path).IsValidPath(); @@ -150,22 +145,22 @@ namespace NzbDrone.Common return Directory.CreateDirectory(path).FullName; } - public virtual void CopyDirectory(string source, string target) + public virtual void CopyFolder(string source, string target) { Ensure.That(() => source).IsValidPath(); Ensure.That(() => target).IsValidPath(); - TransferDirectory(source, target, TransferAction.Copy); + TransferFolder(source, target, TransferAction.Copy); } - public virtual void MoveDirectory(string source, string destination) + public virtual void MoveFolder(string source, string destination) { Ensure.That(() => source).IsValidPath(); Ensure.That(() => destination).IsValidPath(); try { - TransferDirectory(source, destination, TransferAction.Move); + TransferFolder(source, destination, TransferAction.Move); Directory.Delete(source, true); } catch (Exception e) @@ -176,7 +171,7 @@ namespace NzbDrone.Common } } - private void TransferDirectory(string source, string target, TransferAction transferAction) + private void TransferFolder(string source, string target, TransferAction transferAction) { Ensure.That(() => source).IsValidPath(); Ensure.That(() => target).IsValidPath(); @@ -193,7 +188,7 @@ namespace NzbDrone.Common foreach (var subDir in sourceFolder.GetDirectories()) { - TransferDirectory(subDir.FullName, Path.Combine(target, subDir.Name), transferAction); + TransferFolder(subDir.FullName, Path.Combine(target, subDir.Name), transferAction); } foreach (var sourceFile in sourceFolder.GetFiles("*.*", SearchOption.TopDirectoryOnly)) @@ -251,20 +246,6 @@ namespace NzbDrone.Common Directory.Delete(path, recursive); } - public virtual DateTime DirectoryDateCreated(string path) - { - Ensure.That(() => path).IsValidPath(); - - return Directory.GetCreationTime(path); - } - - public virtual IEnumerable GetFileInfos(string path, string pattern, SearchOption searchOption) - { - Ensure.That(() => path).IsValidPath(); - - return new DirectoryInfo(path).EnumerateFiles(pattern, searchOption); - } - public virtual void InheritFolderPermissions(string filename) { Ensure.That(() => filename).IsValidPath(); @@ -350,28 +331,13 @@ namespace NzbDrone.Common File.SetLastWriteTimeUtc(path, dateTime); } - public virtual void DirectorySetLastWriteTimeUtc(string path, DateTime dateTime) + public virtual void FolderSetLastWriteTimeUtc(string path, DateTime dateTime) { Ensure.That(() => path).IsValidPath(); Directory.SetLastWriteTimeUtc(path, dateTime); } - public virtual bool IsFolderLocked(string path) - { - Ensure.That(() => path).IsValidPath(); - - var files = GetFileInfos(path, "*.*", SearchOption.AllDirectories); - - foreach (var fileInfo in files) - { - if (IsFileLocked(fileInfo)) - return true; - } - - return false; - } - public virtual bool IsFileLocked(FileInfo file) { FileStream stream = null; @@ -394,17 +360,6 @@ namespace NzbDrone.Common return false; } - public virtual bool IsChildOfPath(string child, string parent) - { - Ensure.That(() => child).IsValidPath(); - Ensure.That(() => parent).IsValidPath(); - - if (Path.GetFullPath(child).StartsWith(Path.GetFullPath(parent))) - return true; - - return false; - } - public virtual string GetPathRoot(string path) { Ensure.That(() => path).IsValidPath(); diff --git a/NzbDrone.Common/Instrumentation/ApplicationLogLayoutRenderer.cs b/NzbDrone.Common/Instrumentation/ApplicationLogLayoutRenderer.cs index 2b7f3bdc5..2493a3f85 100644 --- a/NzbDrone.Common/Instrumentation/ApplicationLogLayoutRenderer.cs +++ b/NzbDrone.Common/Instrumentation/ApplicationLogLayoutRenderer.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Common.Instrumentation public ApplicationLogLayoutRenderer() { - _appData = Path.Combine(new AppDirectoryInfo().GetLogFolder(), "nzbdrone.txt"); + _appData = Path.Combine(new AppFolderInfo(new DiskProvider()).GetLogFolder(), "nzbdrone.txt"); } diff --git a/NzbDrone.Common/Instrumentation/UpdateLogLayoutRenderer.cs b/NzbDrone.Common/Instrumentation/UpdateLogLayoutRenderer.cs index 93293ce1e..d70af85c8 100644 --- a/NzbDrone.Common/Instrumentation/UpdateLogLayoutRenderer.cs +++ b/NzbDrone.Common/Instrumentation/UpdateLogLayoutRenderer.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Common.Instrumentation public UpdateLogLayoutRenderer() { - _appData = Path.Combine(new AppDirectoryInfo().GetUpdateLogFolder(), DateTime.Now.ToString("yy.MM.d-HH.mm") + ".txt"); + _appData = Path.Combine(new AppFolderInfo(new DiskProvider()).GetUpdateLogFolder(), DateTime.Now.ToString("yy.MM.d-HH.mm") + ".txt"); } diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index 23723d7f9..7d3ed29ea 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -149,7 +149,7 @@ - + diff --git a/NzbDrone.Common/PathExtensions.cs b/NzbDrone.Common/PathExtensions.cs index a0051a80a..990c51927 100644 --- a/NzbDrone.Common/PathExtensions.cs +++ b/NzbDrone.Common/PathExtensions.cs @@ -38,12 +38,12 @@ namespace NzbDrone.Common return text.IndexOfAny(Path.GetInvalidPathChars()) >= 0; } - private static string GetProperDirectoryCapitalization(DirectoryInfo dirInfo) + private static string GetProperCapitalization(DirectoryInfo dirInfo) { var parentDirInfo = dirInfo.Parent; if (null == parentDirInfo) return dirInfo.Name; - return Path.Combine(GetProperDirectoryCapitalization(parentDirInfo), + return Path.Combine(GetProperCapitalization(parentDirInfo), parentDirInfo.GetDirectories(dirInfo.Name)[0].Name); } @@ -51,74 +51,74 @@ namespace NzbDrone.Common { var fileInfo = new FileInfo(filename); DirectoryInfo dirInfo = fileInfo.Directory; - return Path.Combine(GetProperDirectoryCapitalization(dirInfo), + return Path.Combine(GetProperCapitalization(dirInfo), dirInfo.GetFiles(fileInfo.Name)[0].Name); } - public static string GetAppDataPath(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetAppDataPath(this IAppFolderInfo appFolderInfo) { - return IAppDirectoryInfo.WorkingDirectory; + return appFolderInfo.AppDataFolder; } - public static string GetLogFolder(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetLogFolder(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetAppDataPath(IAppDirectoryInfo), "logs"); + return Path.Combine(GetAppDataPath(appFolderInfo), "logs"); } - public static string GetConfigPath(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetConfigPath(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetAppDataPath(IAppDirectoryInfo), APP_CONFIG_FILE); + return Path.Combine(GetAppDataPath(appFolderInfo), APP_CONFIG_FILE); } - public static string GetMediaCoverPath(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetMediaCoverPath(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetAppDataPath(IAppDirectoryInfo), "MediaCover"); + return Path.Combine(GetAppDataPath(appFolderInfo), "MediaCover"); } - public static string GetUpdateLogFolder(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetUpdateLogFolder(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetAppDataPath(IAppDirectoryInfo), UPDATE_LOG_FOLDER_NAME); + return Path.Combine(GetAppDataPath(appFolderInfo), UPDATE_LOG_FOLDER_NAME); } - public static string GetUpdateSandboxFolder(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetUpdateSandboxFolder(this IAppFolderInfo appFolderInfo) { - return Path.Combine(IAppDirectoryInfo.SystemTemp, UPDATE_SANDBOX_FOLDER_NAME); + return Path.Combine(appFolderInfo.TempFolder, UPDATE_SANDBOX_FOLDER_NAME); } - public static string GetUpdateBackUpFolder(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetUpdateBackUpFolder(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetUpdateSandboxFolder(IAppDirectoryInfo), UPDATE_BACKUP_FOLDER_NAME); + return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_BACKUP_FOLDER_NAME); } - public static string GetUpdatePackageFolder(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetUpdatePackageFolder(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetUpdateSandboxFolder(IAppDirectoryInfo), UPDATE_PACKAGE_FOLDER_NAME); + return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_PACKAGE_FOLDER_NAME); } - public static string GetUpdateClientFolder(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetUpdateClientFolder(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetUpdatePackageFolder(IAppDirectoryInfo), UPDATE_CLIENT_FOLDER_NAME); + return Path.Combine(GetUpdatePackageFolder(appFolderInfo), UPDATE_CLIENT_FOLDER_NAME); } - public static string GetUpdateClientExePath(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetUpdateClientExePath(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetUpdateSandboxFolder(IAppDirectoryInfo), UPDATE_CLIENT_EXE); + return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_CLIENT_EXE); } - public static string GetConfigBackupFile(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetConfigBackupFile(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetAppDataPath(IAppDirectoryInfo), BACKUP_ZIP_FILE); + return Path.Combine(GetAppDataPath(appFolderInfo), BACKUP_ZIP_FILE); } - public static string GetNzbDroneDatabase(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetNzbDroneDatabase(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetAppDataPath(IAppDirectoryInfo), NZBDRONE_DB); + return Path.Combine(GetAppDataPath(appFolderInfo), NZBDRONE_DB); } - public static string GetLogDatabase(this IAppDirectoryInfo IAppDirectoryInfo) + public static string GetLogDatabase(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetAppDataPath(IAppDirectoryInfo), NZBDRONE_LOG_DB); + return Path.Combine(GetAppDataPath(appFolderInfo), NZBDRONE_LOG_DB); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/Framework/DbTest.cs b/NzbDrone.Core.Test/Framework/DbTest.cs index 48c520c09..09195504e 100644 --- a/NzbDrone.Core.Test/Framework/DbTest.cs +++ b/NzbDrone.Core.Test/Framework/DbTest.cs @@ -117,9 +117,9 @@ namespace NzbDrone.Core.Test.Framework [TearDown] public void TearDown() { - if (TestDirectoryInfo != null) + if (TestFolderInfo != null) { - var files = Directory.GetFiles(TestDirectoryInfo.WorkingDirectory); + var files = Directory.GetFiles(TestFolderInfo.AppDataFolder); foreach (var file in files) { diff --git a/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs b/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs index 33cd7428f..08e7645c3 100644 --- a/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs +++ b/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests [SetUp] public void Setup() { - Mocker.SetConstant(new AppDirectoryInfo()); + Mocker.SetConstant(new AppFolderInfo(new DiskProvider())); } [Test] diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs index 0331c8c65..3de343d70 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests var path = @"C:\Test\TV\30 Rock"; - Mocker.Resolve().DeleteDirectory(path); + Mocker.Resolve().DeleteFolder(path); Mocker.GetMock().Verify(v => v.DeleteFolder(path, true), Times.Once()); } @@ -53,9 +53,9 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests var path = @"C:\Test\TV\30 Rock"; - Mocker.Resolve().DeleteDirectory(path); + Mocker.Resolve().DeleteFolder(path); - Mocker.GetMock().Verify(v => v.MoveDirectory(path, @"C:\Test\Recycle Bin\30 Rock"), Times.Once()); + Mocker.GetMock().Verify(v => v.MoveFolder(path, @"C:\Test\Recycle Bin\30 Rock"), Times.Once()); } [Test] @@ -65,9 +65,9 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests var path = @"C:\Test\TV\30 Rock"; - Mocker.Resolve().DeleteDirectory(path); + Mocker.Resolve().DeleteFolder(path); - Mocker.GetMock().Verify(v => v.DirectorySetLastWriteTimeUtc(@"C:\Test\Recycle Bin\30 Rock", It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.FolderSetLastWriteTimeUtc(@"C:\Test\Recycle Bin\30 Rock", It.IsAny()), Times.Once()); } [Test] @@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests Mocker.GetMock().Setup(s => s.GetFiles(@"C:\Test\Recycle Bin\30 Rock", SearchOption.AllDirectories)) .Returns(new[]{ "File1", "File2", "File3" }); - Mocker.Resolve().DeleteDirectory(path); + Mocker.Resolve().DeleteFolder(path); Mocker.GetMock().Verify(v => v.FileSetLastWriteTimeUtc(It.IsAny(), It.IsAny()), Times.Exactly(3)); } diff --git a/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs b/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs index 86a294faf..da8c3c40e 100644 --- a/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs +++ b/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs @@ -30,12 +30,12 @@ namespace NzbDrone.Core.Test.UpdateTests [SetUp] public void Setup() { - Mocker.GetMock().SetupGet(c => c.SystemTemp).Returns(TempFolder); + Mocker.GetMock().SetupGet(c => c.TempFolder).Returns(TempFolder); Mocker.GetMock().Setup(c => c.AvailableUpdate()).Returns(_updatePackage); Mocker.GetMock().Setup(c => c.GetCurrentProcess()).Returns(new ProcessInfo { Id = 12 }); - _sandboxFolder = Mocker.GetMock().Object.GetUpdateSandboxFolder(); + _sandboxFolder = Mocker.GetMock().Object.GetUpdateSandboxFolder(); } @@ -87,13 +87,13 @@ namespace NzbDrone.Core.Test.UpdateTests [Test] public void Should_copy_update_client_to_root_of_sandbox() { - var updateClientFolder = Mocker.GetMock().Object.GetUpdateClientFolder(); + var updateClientFolder = Mocker.GetMock().Object.GetUpdateClientFolder(); Subject.Execute(new ApplicationUpdateCommand()); - Mocker.GetMock().Verify(c => c.MoveDirectory(updateClientFolder, _sandboxFolder)); + Mocker.GetMock().Verify(c => c.MoveFolder(updateClientFolder, _sandboxFolder)); } [Test] @@ -124,7 +124,7 @@ namespace NzbDrone.Core.Test.UpdateTests { UseRealHttp(); - var updateSubFolder = new DirectoryInfo(Mocker.GetMock().Object.GetUpdateSandboxFolder()); + var updateSubFolder = new DirectoryInfo(Mocker.GetMock().Object.GetUpdateSandboxFolder()); updateSubFolder.Exists.Should().BeFalse(); diff --git a/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 4bc5ecb9f..646f0ab62 100644 --- a/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -25,16 +25,16 @@ namespace NzbDrone.Core.Configuration public class ConfigFileProvider : IConfigFileProvider { - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; private readonly ICached _cache; private readonly string _configFile; - public ConfigFileProvider(IAppDirectoryInfo appDirectoryInfo, ICacheManger cacheManger) + public ConfigFileProvider(IAppFolderInfo appFolderInfo, ICacheManger cacheManger) { - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; _cache = cacheManger.GetCache(this.GetType()); - _configFile = _appDirectoryInfo.GetConfigPath(); + _configFile = _appFolderInfo.GetConfigPath(); } public Dictionary GetConfigDictionary() diff --git a/NzbDrone.Core/Datastore/ConnectionStringFactory.cs b/NzbDrone.Core/Datastore/ConnectionStringFactory.cs index ec0b5b279..312df4cc8 100644 --- a/NzbDrone.Core/Datastore/ConnectionStringFactory.cs +++ b/NzbDrone.Core/Datastore/ConnectionStringFactory.cs @@ -13,10 +13,10 @@ namespace NzbDrone.Core.Datastore public class ConnectionStringFactory : IConnectionStringFactory { - public ConnectionStringFactory(IAppDirectoryInfo appDirectoryInfo) + public ConnectionStringFactory(IAppFolderInfo appFolderInfo) { - MainDbConnectionString = GetConnectionString(appDirectoryInfo.GetNzbDroneDatabase()); - LogDbConnectionString = GetConnectionString(appDirectoryInfo.GetLogDatabase()); + MainDbConnectionString = GetConnectionString(appFolderInfo.GetNzbDroneDatabase()); + LogDbConnectionString = GetConnectionString(appFolderInfo.GetLogDatabase()); } public string MainDbConnectionString { get; private set; } diff --git a/NzbDrone.Core/MediaCover/MediaCoverService.cs b/NzbDrone.Core/MediaCover/MediaCoverService.cs index dc896d9e6..9edbec187 100644 --- a/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Core.MediaCover private readonly string _coverRootFolder; - public MediaCoverService(IHttpProvider httpProvider, IDiskProvider diskProvider, IAppDirectoryInfo appDirectoryInfo, + public MediaCoverService(IHttpProvider httpProvider, IDiskProvider diskProvider, IAppFolderInfo appFolderInfo, ICoverExistsSpecification coverExistsSpecification, Logger logger) { _httpProvider = httpProvider; @@ -30,7 +30,7 @@ namespace NzbDrone.Core.MediaCover _coverExistsSpecification = coverExistsSpecification; _logger = logger; - _coverRootFolder = appDirectoryInfo.GetMediaCoverPath(); + _coverRootFolder = appFolderInfo.GetMediaCoverPath(); } public void HandleAsync(SeriesUpdatedEvent message) diff --git a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs index 9bed9c53f..b015f5a00 100644 --- a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs +++ b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Core.MediaFiles { ProcessSubFolder(new DirectoryInfo(subfolder)); - if (_diskProvider.GetDirectorySize(subfolder) < 50.Megabytes()) + if (_diskProvider.GetFolderSize(subfolder) < 50.Megabytes()) { _diskProvider.DeleteFolder(subfolder, true); } diff --git a/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs b/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs index 103adcc42..fbf664d11 100644 --- a/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs +++ b/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.MediaFiles { } - public virtual void DeleteDirectory(string path) + public virtual void DeleteFolder(string path) { logger.Trace("Attempting to send '{0}' to recycling bin", path); var recyclingBin = _configService.RecycleBin; @@ -43,10 +43,10 @@ namespace NzbDrone.Core.MediaFiles var destination = Path.Combine(recyclingBin, new DirectoryInfo(path).Name); logger.Trace("Moving '{0}' to '{1}'", path, destination); - _diskProvider.MoveDirectory(path, destination); + _diskProvider.MoveFolder(path, destination); logger.Trace("Setting last accessed: {0}", path); - _diskProvider.DirectorySetLastWriteTimeUtc(destination, DateTime.UtcNow); + _diskProvider.FolderSetLastWriteTimeUtc(destination, DateTime.UtcNow); foreach (var file in _diskProvider.GetFiles(destination, SearchOption.AllDirectories)) { _diskProvider.FileSetLastWriteTimeUtc(file, DateTime.UtcNow); @@ -141,7 +141,7 @@ namespace NzbDrone.Core.MediaFiles { if (message.DeleteFiles) { - DeleteDirectory(message.Series.Path); + DeleteFolder(message.Series.Path); } } diff --git a/NzbDrone.Core/Providers/BackupProvider.cs b/NzbDrone.Core/Providers/BackupProvider.cs index bb3abe315..e0083fa65 100644 --- a/NzbDrone.Core/Providers/BackupProvider.cs +++ b/NzbDrone.Core/Providers/BackupProvider.cs @@ -8,11 +8,11 @@ namespace NzbDrone.Core.Providers { public class BackupProvider { - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; - public BackupProvider(IAppDirectoryInfo appDirectoryInfo) + public BackupProvider(IAppFolderInfo appFolderInfo) { - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; } public BackupProvider() @@ -21,8 +21,8 @@ namespace NzbDrone.Core.Providers public virtual string CreateBackupZip() { - var configFile = _appDirectoryInfo.GetConfigPath(); - var zipFile = _appDirectoryInfo.GetConfigBackupFile(); + var configFile = _appFolderInfo.GetConfigPath(); + var zipFile = _appFolderInfo.GetConfigBackupFile(); using (var zip = new ZipFile()) { diff --git a/NzbDrone.Core/Update/InstallUpdateService.cs b/NzbDrone.Core/Update/InstallUpdateService.cs index f65cc0bd1..0c174cbf9 100644 --- a/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/NzbDrone.Core/Update/InstallUpdateService.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Core.Update { private readonly ICheckUpdateService _checkUpdateService; private readonly Logger _logger; - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; private readonly IDiskProvider _diskProvider; private readonly IHttpProvider _httpProvider; @@ -20,12 +20,12 @@ namespace NzbDrone.Core.Update private readonly IProcessProvider _processProvider; - public InstallUpdateService(ICheckUpdateService checkUpdateService, IAppDirectoryInfo appDirectoryInfo, + public InstallUpdateService(ICheckUpdateService checkUpdateService, IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, IHttpProvider httpProvider, ArchiveProvider archiveProvider, IProcessProvider processProvider, Logger logger) { _checkUpdateService = checkUpdateService; - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; _diskProvider = diskProvider; _httpProvider = httpProvider; _archiveProvider = archiveProvider; @@ -45,7 +45,7 @@ namespace NzbDrone.Core.Update private void InstallUpdate(UpdatePackage updatePackage) { - var updateSandboxFolder = _appDirectoryInfo.GetUpdateSandboxFolder(); + var updateSandboxFolder = _appFolderInfo.GetUpdateSandboxFolder(); var packageDestination = Path.Combine(updateSandboxFolder, updatePackage.FileName); @@ -64,14 +64,14 @@ namespace NzbDrone.Core.Update _logger.Info("Update package extracted successfully"); _logger.Info("Preparing client"); - _diskProvider.MoveDirectory(_appDirectoryInfo.GetUpdateClientFolder(), + _diskProvider.MoveFolder(_appFolderInfo.GetUpdateClientFolder(), updateSandboxFolder); _logger.Info("Starting update client"); var startInfo = new ProcessStartInfo { - FileName = _appDirectoryInfo.GetUpdateClientExePath(), + FileName = _appFolderInfo.GetUpdateClientExePath(), Arguments = _processProvider.GetCurrentProcess().Id.ToString() }; diff --git a/NzbDrone.Integration.Test/IntegrationTest.cs b/NzbDrone.Integration.Test/IntegrationTest.cs index a95f74015..6ee81b507 100644 --- a/NzbDrone.Integration.Test/IntegrationTest.cs +++ b/NzbDrone.Integration.Test/IntegrationTest.cs @@ -58,7 +58,7 @@ namespace NzbDrone.Integration.Test public void SmokeTestSetup() { Container = MainAppContainerBuilder.BuildContainer(); - Container.Register(typeof(IAppDirectoryInfo), new IntegrationTestDirectoryInfo()); + Container.Register(typeof(IAppFolderInfo), new IntegrationTestFolderInfo()); DbFactory.RegisterDatabase(Container); diff --git a/NzbDrone.Integration.Test/IntegrationTestDirectoryInfo.cs b/NzbDrone.Integration.Test/IntegrationTestDirectoryInfo.cs index 0a80eb9a1..922a9537c 100644 --- a/NzbDrone.Integration.Test/IntegrationTestDirectoryInfo.cs +++ b/NzbDrone.Integration.Test/IntegrationTestDirectoryInfo.cs @@ -4,23 +4,23 @@ using NzbDrone.Common.EnvironmentInfo; namespace NzbDrone.Integration.Test { - public class IntegrationTestDirectoryInfo : IAppDirectoryInfo + public class IntegrationTestFolderInfo : IAppFolderInfo { - public IntegrationTestDirectoryInfo() + public IntegrationTestFolderInfo() { - SystemTemp = Path.GetTempPath(); - WorkingDirectory = Path.Combine(Directory.GetCurrentDirectory(), "integ_test", DateTime.Now.Ticks.ToString()); + TempFolder = Path.GetTempPath(); + AppDataFolder = Path.Combine(Directory.GetCurrentDirectory(), "integ_test", DateTime.Now.Ticks.ToString()); - if (!Directory.Exists(WorkingDirectory)) + if (!Directory.Exists(AppDataFolder)) { - Directory.CreateDirectory(WorkingDirectory); + Directory.CreateDirectory(AppDataFolder); } - StartUpPath = Directory.GetCurrentDirectory(); + StartUpFolder = Directory.GetCurrentDirectory(); } - public string WorkingDirectory { get; private set; } - public string SystemTemp { get; private set; } - public string StartUpPath { get; private set; } + public string AppDataFolder { get; private set; } + public string TempFolder { get; private set; } + public string StartUpFolder { get; private set; } } } \ No newline at end of file diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index 5611edf32..7a1cd588d 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -108,7 +108,7 @@ namespace NzbDrone.Test.Common } - protected IAppDirectoryInfo TestDirectoryInfo { get; private set; } + protected IAppFolderInfo TestFolderInfo { get; private set; } protected void WindowsOnly() { @@ -129,11 +129,11 @@ namespace NzbDrone.Test.Common protected void WithTempAsAppPath() { - Mocker.GetMock() - .SetupGet(c => c.WorkingDirectory) + Mocker.GetMock() + .SetupGet(c => c.AppDataFolder) .Returns(VirtualPath); - TestDirectoryInfo = Mocker.GetMock().Object; + TestFolderInfo = Mocker.GetMock().Object; } protected string GetTestFilePath(string fileName) diff --git a/NzbDrone.Update.Test/InstallUpdateServiceFixture.cs b/NzbDrone.Update.Test/InstallUpdateServiceFixture.cs index af5b9279d..b7a4515ee 100644 --- a/NzbDrone.Update.Test/InstallUpdateServiceFixture.cs +++ b/NzbDrone.Update.Test/InstallUpdateServiceFixture.cs @@ -15,8 +15,8 @@ namespace NzbDrone.Update.Test [SetUp] public void Setup() { - Mocker.GetMock() - .Setup(c => c.SystemTemp).Returns(@"C:\Temp\"); + Mocker.GetMock() + .Setup(c => c.TempFolder).Returns(@"C:\Temp\"); } [TestCase(null)] diff --git a/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs b/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs index fe4886049..78c3b8c73 100644 --- a/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs +++ b/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs @@ -13,27 +13,27 @@ namespace NzbDrone.Update.UpdateEngine public class BackupAndRestore : IBackupAndRestore { private readonly IDiskProvider _diskProvider; - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; private readonly Logger _logger; - public BackupAndRestore(IDiskProvider diskProvider, IAppDirectoryInfo appDirectoryInfo, Logger logger) + public BackupAndRestore(IDiskProvider diskProvider, IAppFolderInfo appFolderInfo, Logger logger) { _diskProvider = diskProvider; - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; _logger = logger; } public void BackUp(string source) { _logger.Info("Creating backup of existing installation"); - _diskProvider.CopyDirectory(source, _appDirectoryInfo.GetUpdateBackUpFolder()); + _diskProvider.CopyFolder(source, _appFolderInfo.GetUpdateBackUpFolder()); } public void Restore(string target) { //TODO:this should ignore single file failures. _logger.Info("Attempting to rollback upgrade"); - _diskProvider.CopyDirectory(_appDirectoryInfo.GetUpdateBackUpFolder(), target); + _diskProvider.CopyFolder(_appFolderInfo.GetUpdateBackUpFolder(), target); } } } \ No newline at end of file diff --git a/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs b/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs index 1e2d01abf..ffafff691 100644 --- a/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs +++ b/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs @@ -16,18 +16,18 @@ namespace NzbDrone.Update.UpdateEngine private readonly IDiskProvider _diskProvider; private readonly IDetectApplicationType _detectApplicationType; private readonly ITerminateNzbDrone _terminateNzbDrone; - private readonly IAppDirectoryInfo _appDirectoryInfo; + private readonly IAppFolderInfo _appFolderInfo; private readonly IBackupAndRestore _backupAndRestore; private readonly IStartNzbDrone _startNzbDrone; private readonly Logger _logger; public InstallUpdateService(IDiskProvider diskProvider, IDetectApplicationType detectApplicationType, ITerminateNzbDrone terminateNzbDrone, - IAppDirectoryInfo appDirectoryInfo, IBackupAndRestore backupAndRestore, IStartNzbDrone startNzbDrone, Logger logger) + IAppFolderInfo appFolderInfo, IBackupAndRestore backupAndRestore, IStartNzbDrone startNzbDrone, Logger logger) { _diskProvider = diskProvider; _detectApplicationType = detectApplicationType; _terminateNzbDrone = terminateNzbDrone; - _appDirectoryInfo = appDirectoryInfo; + _appFolderInfo = appFolderInfo; _backupAndRestore = backupAndRestore; _startNzbDrone = startNzbDrone; _logger = logger; @@ -44,8 +44,8 @@ namespace NzbDrone.Update.UpdateEngine throw new DirectoryNotFoundException("Target folder doesn't exist " + targetFolder); _logger.Info("Verifying Update Folder"); - if (!_diskProvider.FolderExists(_appDirectoryInfo.GetUpdatePackageFolder())) - throw new DirectoryNotFoundException("Update folder doesn't exist " + _appDirectoryInfo.GetUpdatePackageFolder()); + if (!_diskProvider.FolderExists(_appFolderInfo.GetUpdatePackageFolder())) + throw new DirectoryNotFoundException("Update folder doesn't exist " + _appFolderInfo.GetUpdatePackageFolder()); } public void Start(string installationFolder) @@ -64,7 +64,7 @@ namespace NzbDrone.Update.UpdateEngine try { - _diskProvider.CopyDirectory(_appDirectoryInfo.GetUpdatePackageFolder(), installationFolder); + _diskProvider.CopyFolder(_appFolderInfo.GetUpdatePackageFolder(), installationFolder); } catch (Exception e) {