moved data from Roaming to ProgramData.

Cleaned up DiskProvider
This commit is contained in:
kay.one 2013-07-04 21:43:28 -07:00
commit d60b863e14
33 changed files with 202 additions and 242 deletions

View file

@ -14,21 +14,21 @@ namespace NzbDrone.Api.Client
{
public class ClientSettings : IHandle<ApplicationStartedEvent>
{
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;

View file

@ -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<string>(typeof(IndexModule));
//Serve anything that doesn't have an extension

View file

@ -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)

View file

@ -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)

View file

@ -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,