Removed RemotePathMapping infrastructure. OutputPath on items is now DownloadClientPath.

This commit is contained in:
Taloth Saldono 2017-12-16 09:52:43 +01:00
parent e089bfb4d2
commit 5c1491ca06
31 changed files with 94 additions and 327 deletions

View File

@ -15,7 +15,6 @@ using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Notifications;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
@ -106,7 +105,6 @@ namespace NzbDrone.Core.Datastore
Mapper.Entity<PendingRelease>().RegisterModel("PendingReleases")
.Ignore(e => e.RemoteEpisode);
Mapper.Entity<RemotePathMapping>().RegisterModel("RemotePathMappings");
Mapper.Entity<Tag>().RegisterModel("Tags");
Mapper.Entity<Restriction>().RegisterModel("Restrictions");

View File

@ -11,7 +11,6 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Download.Clients.Blackhole
@ -29,9 +28,8 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
_scanWatchFolder = scanWatchFolder;
@ -99,7 +97,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
TotalSize = item.TotalSize,
RemainingTime = item.RemainingTime,
OutputPath = item.OutputPath,
OutputPath = new DownloadClientPath(Definition.Id, item.OutputPath),
Status = item.Status,
@ -124,7 +122,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
return new DownloadClientInfo
{
IsLocalhost = true,
OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) }
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(Settings.WatchFolder)) }
};
}

View File

@ -9,7 +9,6 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Blackhole
{
@ -23,10 +22,9 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IValidateNzbs nzbValidationService,
Logger logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
{
_scanWatchFolder = scanWatchFolder;
@ -67,7 +65,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
TotalSize = item.TotalSize,
RemainingTime = item.RemainingTime,
OutputPath = item.OutputPath,
OutputPath = new DownloadClientPath(Definition.Id, item.OutputPath),
Status = item.Status,
@ -92,7 +90,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
return new DownloadClientInfo
{
IsLocalhost = true,
OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) }
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(Settings.WatchFolder)) }
};
}

View File

@ -11,7 +11,6 @@ using NzbDrone.Core.Validation;
using NLog;
using FluentValidation.Results;
using System.Net;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Deluge
{
@ -24,9 +23,8 @@ namespace NzbDrone.Core.Download.Clients.Deluge
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
_proxy = proxy;
}
@ -106,8 +104,8 @@ namespace NzbDrone.Core.Download.Clients.Deluge
item.DownloadClient = Definition.Name;
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.DownloadPath));
item.OutputPath = outputPath + torrent.Name;
var outputPath = new OsPath(torrent.DownloadPath) + torrent.Name;
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
item.RemainingSize = torrent.Size - torrent.BytesDownloaded;
try
@ -176,7 +174,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
if (!destDir.IsEmpty)
{
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
}
return status;

View File

@ -12,7 +12,6 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.DownloadStation
@ -34,9 +33,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
_dsInfoProxy = dsInfoProxy;
_dsTaskProxy = dsTaskProxy;
@ -96,7 +94,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
{
item.OutputPath = GetOutputPath(outputPath, torrent, serialNumber);
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, torrent, serialNumber));
}
items.Add(item);
@ -114,7 +112,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(path)) }
};
}
catch (DownloadClientException e)
@ -140,9 +138,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
var fullPath = _sharedFolderResolver.RemapToFullPath(outputPath, Settings, serialNumber);
var remotePath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, fullPath);
var finalPath = remotePath + torrent.Title;
var finalPath = fullPath + torrent.Title;
return finalPath;
}

View File

@ -10,7 +10,6 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.DownloadStation
@ -31,11 +30,10 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IValidateNzbs nzbValidationService,
Logger logger
)
: base(httpClient, configService, diskProvider, remotePathMappingService, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
{
_dsInfoProxy = dsInfoProxy;
_dsTaskProxy = dsTaskProxy;
@ -111,7 +109,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
{
item.OutputPath = GetOutputPath(outputPath, nzb, serialNumber);
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, nzb, serialNumber));
}
items.Add(item);
@ -124,7 +122,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
var fullPath = _sharedFolderResolver.RemapToFullPath(outputPath, Settings, serialNumber);
var remotePath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, fullPath);
var remotePath = fullPath;
var finalPath = remotePath + task.Title;
@ -140,7 +138,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(path)) }
};
}
catch (DownloadClientException e)

View File

@ -10,7 +10,6 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Hadouken.Models;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.Hadouken
@ -24,9 +23,8 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
_proxy = proxy;
}
@ -46,7 +44,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
continue;
}
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath));
var outputPath = new OsPath(torrent.SavePath);
var eta = TimeSpan.FromSeconds(0);
if (torrent.DownloadRate > 0 && torrent.TotalSize > 0)
@ -58,7 +56,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
{
DownloadClient = Definition.Name,
DownloadId = torrent.InfoHash.ToUpper(),
OutputPath = outputPath + torrent.Name,
OutputPath = new DownloadClientPath(Definition.Id, outputPath + torrent.Name),
RemainingSize = torrent.TotalSize - torrent.DownloadedBytes,
RemainingTime = eta,
Title = torrent.Name,
@ -119,7 +117,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
if (!destDir.IsEmpty)
{
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
}
return status;

View File

@ -10,7 +10,6 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Validation;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.NzbVortex
{
@ -22,10 +21,9 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IValidateNzbs nzbValidationService,
Logger logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
{
_proxy = proxy;
}
@ -88,7 +86,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
break;
}
queueItem.OutputPath = GetOutputPath(vortexQueueItem, queueItem);
queueItem.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(vortexQueueItem, queueItem));
if (vortexQueueItem.State == NzbVortexStateType.PasswordRequest)
{
@ -221,7 +219,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
private OsPath GetOutputPath(NzbVortexQueueItem vortexQueueItem, DownloadClientItem queueItem)
{
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(vortexQueueItem.DestinationPath));
var outputPath = new OsPath(vortexQueueItem.DestinationPath);
if (outputPath.FileName == vortexQueueItem.UiTitle)
{

View File

@ -10,7 +10,6 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.Nzbget
@ -25,10 +24,9 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IValidateNzbs nzbValidationService,
Logger logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
{
_proxy = proxy;
}
@ -123,7 +121,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
historyItem.DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString();
historyItem.Title = item.Name;
historyItem.TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo);
historyItem.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir));
historyItem.OutputPath = new DownloadClientPath(Definition.Id, new OsPath(item.DestDir));
historyItem.Category = item.Category;
historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}";
historyItem.Status = DownloadItemStatus.Completed;
@ -208,7 +206,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
if (category != null)
{
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(category.DestDir)) };
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(category.DestDir)) };
}
return status;

View File

@ -8,7 +8,6 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
@ -21,9 +20,8 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
public Pneumatic(IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(configService, diskProvider, remotePathMappingService, logger)
: base(configService, diskProvider, logger)
{
_httpClient = httpClient;
}
@ -82,7 +80,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
TotalSize = _diskProvider.GetFileSize(file),
OutputPath = new OsPath(file)
OutputPath = new DownloadClientPath(Definition.Id, new OsPath(file))
};
if (_diskProvider.IsFileLocked(file))

View File

@ -11,7 +11,6 @@ using NzbDrone.Core.Validation;
using FluentValidation.Results;
using System.Net;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.QBittorrent
{
@ -24,9 +23,8 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
_proxy = proxy;
}
@ -109,16 +107,17 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
item.RemainingSize = (long)(torrent.Size * (1.0 - torrent.Progress));
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath));
var outputPath = new OsPath(torrent.SavePath);
if (!outputPath.IsEmpty && outputPath.FileName != torrent.Name)
{
outputPath += torrent.Name;
}
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
// Avoid removing torrents that haven't reached the global max ratio.
// Removal also requires the torrent to be paused, in case a higher max ratio was set on the torrent itself (which is not exposed by the api).
item.CanMoveFiles = item.CanBeRemoved = (!config.MaxRatioEnabled || config.MaxRatio <= torrent.Ratio) && torrent.State == "pausedUP";
if (!item.OutputPath.IsEmpty && item.OutputPath.FileName != torrent.Name)
{
item.OutputPath += torrent.Name;
}
switch (torrent.State)
{
@ -176,7 +175,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) }
};
}

View File

@ -10,7 +10,6 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Validation;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Sabnzbd
{
@ -22,10 +21,9 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IValidateNzbs nzbValidationService,
Logger logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
{
_proxy = proxy;
}
@ -163,23 +161,22 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
historyItem.Status = DownloadItemStatus.Downloading;
}
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(sabHistoryItem.Storage));
var outputPath = new OsPath(sabHistoryItem.Storage);
if (!outputPath.IsEmpty)
{
historyItem.OutputPath = outputPath;
var parent = outputPath.Directory;
while (!parent.IsEmpty)
{
if (parent.FileName == sabHistoryItem.Title)
{
historyItem.OutputPath = parent;
outputPath = parent;
}
parent = parent.Directory;
}
}
historyItem.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
}
historyItems.Add(historyItem);
}
@ -261,7 +258,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
if (category != null)
{
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, category.FullPath) };
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, category.FullPath) };
}
return status;

View File

@ -6,7 +6,6 @@ using NzbDrone.Core.Configuration;
using NLog;
using FluentValidation.Results;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Transmission
{
@ -17,9 +16,8 @@ namespace NzbDrone.Core.Download.Clients.Transmission
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
}

View File

@ -10,7 +10,6 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.Transmission
@ -24,9 +23,8 @@ namespace NzbDrone.Core.Download.Clients.Transmission
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
_proxy = proxy;
}
@ -54,8 +52,6 @@ namespace NzbDrone.Core.Download.Clients.Transmission
if (!directories.Contains(Settings.TvCategory)) continue;
}
outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, outputPath);
var item = new DownloadClientItem();
item.DownloadId = torrent.HashString.ToUpper();
item.Category = Settings.TvCategory;
@ -63,7 +59,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
item.DownloadClient = Definition.Name;
item.OutputPath = GetOutputPath(outputPath, torrent);
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, torrent));
item.TotalSize = torrent.TotalSize;
item.RemainingSize = torrent.LeftUntilDone;
if (torrent.Eta >= 0)
@ -122,7 +118,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(destDir)) }
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(destDir)) }
};
}

View File

@ -5,7 +5,6 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Transmission;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Vuze
{
@ -18,9 +17,8 @@ namespace NzbDrone.Core.Download.Clients.Vuze
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
}

View File

@ -13,7 +13,6 @@ using FluentValidation.Results;
using NzbDrone.Core.Download.Clients.rTorrent;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Download.Clients.RTorrent
@ -28,10 +27,9 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IRTorrentDirectoryValidator rTorrentDirectoryValidator,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
_proxy = proxy;
_rTorrentDirectoryValidator = rTorrentDirectoryValidator;
@ -100,7 +98,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
item.DownloadClient = Definition.Name;
item.Title = torrent.Name;
item.DownloadId = torrent.Hash;
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.Path));
item.OutputPath = new DownloadClientPath(Definition.Id, new OsPath(torrent.Path));
item.TotalSize = torrent.TotalSize;
item.RemainingSize = torrent.RemainingSize;
item.Category = torrent.Category;

View File

@ -11,7 +11,6 @@ using NzbDrone.Core.Validation;
using FluentValidation.Results;
using System.Net;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Common.Cache;
namespace NzbDrone.Core.Download.Clients.UTorrent
@ -27,9 +26,8 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
{
_proxy = proxy;
@ -99,16 +97,13 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
}
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.RootDownloadPath));
var outputPath = new OsPath(torrent.RootDownloadPath);
if (outputPath == null || outputPath.FileName == torrent.Name)
if (outputPath != null && outputPath.FileName != torrent.Name)
{
item.OutputPath = outputPath;
}
else
{
item.OutputPath = outputPath + torrent.Name;
outputPath += torrent.Name;
}
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
if (torrent.Status.HasFlag(UTorrentTorrentStatus.Error))
{
@ -209,7 +204,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
if (!destDir.IsEmpty)
{
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
}
return status;

View File

@ -8,7 +8,6 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@ -19,7 +18,6 @@ namespace NzbDrone.Core.Download
{
protected readonly IConfigService _configService;
protected readonly IDiskProvider _diskProvider;
protected readonly IRemotePathMappingService _remotePathMappingService;
protected readonly Logger _logger;
public abstract string Name { get; }
@ -38,12 +36,10 @@ namespace NzbDrone.Core.Download
protected DownloadClientBase(IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
{
_configService = configService;
_diskProvider = diskProvider;
_remotePathMappingService = remotePathMappingService;
_logger = logger;
}
@ -76,6 +72,9 @@ namespace NzbDrone.Core.Download
return;
}
// FIXME: Doesn't work if remote.
throw new NotSupportedException();
/*
if (item.OutputPath.IsEmpty)
{
_logger.Trace("[{0}] Doesn't have an outputPath, skipping delete data.", item.Title);
@ -104,7 +103,7 @@ namespace NzbDrone.Core.Download
catch (Exception ex)
{
_logger.Warn(ex, string.Format("[{0}] Error occurred while trying to delete data from '{1}'.", item.Title, item.OutputPath));
}
}*/
}
public ValidationResult Test()

View File

@ -6,6 +6,6 @@ namespace NzbDrone.Core.Download
public class DownloadClientInfo
{
public bool IsLocalhost { get; set; }
public List<OsPath> OutputRootFolders { get; set; }
public List<DownloadClientPath> OutputRootFolders { get; set; }
}
}

View File

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Download
public long RemainingSize { get; set; }
public TimeSpan? RemainingTime { get; set; }
public OsPath OutputPath { get; set; }
public DownloadClientPath OutputPath { get; set; }
public string Message { get; set; }
public DownloadItemStatus Status { get; set; }

View File

@ -1,8 +1,16 @@
namespace NzbDrone.Core.Download
using NzbDrone.Common.Disk;
namespace NzbDrone.Core.Download
{
public class DownloadClientPath
{
public int DownloadClientId { get; set; }
public string Path { get; set; }
public OsPath Path { get; set; }
public DownloadClientPath(int downloadClientId, OsPath path)
{
DownloadClientId = downloadClientId;
Path = path;
}
}
}

View File

@ -12,7 +12,6 @@ using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Configuration;
using NLog;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download
{
@ -26,9 +25,8 @@ namespace NzbDrone.Core.Download
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(configService, diskProvider, remotePathMappingService, logger)
: base(configService, diskProvider, logger)
{
_httpClient = httpClient;
_torrentFileInfoReader = torrentFileInfoReader;

View File

@ -8,7 +8,6 @@ using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Configuration;
using NLog;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download
{
@ -21,10 +20,9 @@ namespace NzbDrone.Core.Download
protected UsenetClientBase(IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IValidateNzbs nzbValidationService,
Logger logger)
: base(configService, diskProvider, remotePathMappingService, logger)
: base(configService, diskProvider, logger)
{
_httpClient = httpClient;
_nzbValidationService = nzbValidationService;

View File

@ -949,7 +949,6 @@
<Compile Include="Qualities\Revision.cs" />
<Compile Include="TransferProviders\Providers\DefaultTransfer.cs" />
<Compile Include="TransferProviders\Providers\DirectVirtualDiskProvider.cs" />
<Compile Include="TransferProviders\Providers\Dummy.cs" />
<Compile Include="TransferProviders\Providers\EmptyVirtualDiskProvider.cs" />
<Compile Include="TransferProviders\Providers\MountVirtualDiskProvider.cs" />
<Compile Include="TransferProviders\TransferProviderDefinition.cs" />
@ -958,9 +957,6 @@
<Compile Include="TransferProviders\ITransferProvider.cs" />
<Compile Include="TransferProviders\IVirtualDiskProvider.cs" />
<Compile Include="TransferProviders\Providers\MountTransfer.cs" />
<Compile Include="TransferProviders\old\RemotePathMapping.cs" />
<Compile Include="TransferProviders\old\RemotePathMappingRepository.cs" />
<Compile Include="TransferProviders\old\RemotePathMappingService.cs" />
<Compile Include="MediaFiles\TorrentInfo\TorrentFileInfoReader.cs" />
<Compile Include="Notifications\DownloadMessage.cs" />
<Compile Include="Notifications\Email\Email.cs">

View File

@ -73,7 +73,7 @@ namespace NzbDrone.Core.TransferProviders.Providers
protected string ResolvePath(DownloadClientPath path)
{
return path.Path;
return path.Path.FullPath;
}
}
}

View File

@ -8,7 +8,6 @@ namespace NzbDrone.Core.TransferProviders.Providers
{
public bool SupportStreaming => true;
public string[] GetFiles()
{
return new string[0];

View File

@ -11,7 +11,6 @@ using NzbDrone.Core.Validation;
namespace NzbDrone.Core.TransferProviders.Providers
{
// Indicates that the remote path is mounted locally, and thus should honor the DownloadItem isReadonly flag and may transfer slowly.
public class MountSettings : IProviderConfig
{
public string DownloadClientPath { get; set; }
@ -48,6 +47,10 @@ namespace NzbDrone.Core.TransferProviders.Providers
if (item == null) return false;
var path = ResolvePath(item);
if (path == null)
{
return false;
}
return _diskProvider.FolderExists(path) || _diskProvider.FileExists(path);
}
@ -69,8 +72,15 @@ namespace NzbDrone.Core.TransferProviders.Providers
protected string ResolvePath(DownloadClientPath path)
{
// Same logic as RemotePathMapping service.
throw new NotImplementedException();
var remotePath = path.Path;
if (new OsPath(Settings.DownloadClientPath).Contains(remotePath))
{
var localPath = new OsPath(Settings.MountPath) + (remotePath - new OsPath(Settings.DownloadClientPath));
return localPath.FullPath;
}
return null;
}
}
}

View File

@ -10,20 +10,16 @@ namespace NzbDrone.Core.TransferProviders
public abstract class TransferProviderBase<TSettings> : ITransferProvider where TSettings : IProviderConfig, new()
{
public abstract string Name { get; }
public Type ConfigContract => typeof(TSettings);
public virtual ProviderMessage Message => null;
public virtual IEnumerable<ProviderDefinition> DefaultDefinitions => new List<ProviderDefinition>();
public ProviderDefinition Definition { get; set; }
public abstract ValidationResult Test();
public virtual object RequestAction(string action, IDictionary<string, string> query) { return null; }
public abstract bool IsAvailable(DownloadClientPath item);
protected TSettings Settings => (TSettings)Definition.Settings;
public abstract bool IsAvailable(DownloadClientPath item);
public abstract IVirtualDiskProvider GetFileSystemWrapper(DownloadClientPath item, string tempPath = null);
}
}

View File

@ -1,12 +0,0 @@
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.RemotePathMappings
{
public class RemotePathMapping : ModelBase
{
public string Host { get; set; }
public string RemotePath { get; set; }
public string LocalPath { get; set; }
}
}

View File

@ -1,21 +0,0 @@
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.RemotePathMappings
{
public interface IRemotePathMappingRepository : IBasicRepository<RemotePathMapping>
{
}
public class RemotePathMappingRepository : BasicRepository<RemotePathMapping>, IRemotePathMappingRepository
{
public RemotePathMappingRepository(IMainDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
{
}
protected override bool PublishModelEvents => true;
}
}

View File

@ -1,163 +0,0 @@
using System.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Cache;
using NzbDrone.Core.Download;
namespace NzbDrone.Core.RemotePathMappings
{
public interface IRemotePathMappingService
{
List<RemotePathMapping> All();
RemotePathMapping Add(RemotePathMapping mapping);
void Remove(int id);
RemotePathMapping Get(int id);
RemotePathMapping Update(RemotePathMapping mapping);
OsPath RemapRemoteToLocal(string host, OsPath remotePath);
OsPath RemapLocalToRemote(string host, OsPath localPath);
}
public class RemotePathMappingService : IRemotePathMappingService
{
private readonly IRemotePathMappingRepository _remotePathMappingRepository;
private readonly IDiskProvider _diskProvider;
private readonly Logger _logger;
private readonly ICached<List<RemotePathMapping>> _cache;
public RemotePathMappingService(IDownloadClientRepository downloadClientRepository,
IRemotePathMappingRepository remotePathMappingRepository,
IDiskProvider diskProvider,
ICacheManager cacheManager,
Logger logger)
{
_remotePathMappingRepository = remotePathMappingRepository;
_diskProvider = diskProvider;
_logger = logger;
_cache = cacheManager.GetCache<List<RemotePathMapping>>(GetType());
}
public List<RemotePathMapping> All()
{
return _cache.Get("all", () => _remotePathMappingRepository.All().ToList(), TimeSpan.FromSeconds(10));
}
public RemotePathMapping Add(RemotePathMapping mapping)
{
mapping.LocalPath = new OsPath(mapping.LocalPath).AsDirectory().FullPath;
mapping.RemotePath = new OsPath(mapping.RemotePath).AsDirectory().FullPath;
var all = All();
ValidateMapping(all, mapping);
var result = _remotePathMappingRepository.Insert(mapping);
_cache.Clear();
return result;
}
public void Remove(int id)
{
_remotePathMappingRepository.Delete(id);
_cache.Clear();
}
public RemotePathMapping Get(int id)
{
return _remotePathMappingRepository.Get(id);
}
public RemotePathMapping Update(RemotePathMapping mapping)
{
var existing = All().Where(v => v.Id != mapping.Id).ToList();
ValidateMapping(existing, mapping);
var result = _remotePathMappingRepository.Update(mapping);
_cache.Clear();
return result;
}
private void ValidateMapping(List<RemotePathMapping> existing, RemotePathMapping mapping)
{
if (mapping.Host.IsNullOrWhiteSpace())
{
throw new ArgumentException("Invalid Host");
}
var remotePath = new OsPath(mapping.RemotePath);
var localPath = new OsPath(mapping.LocalPath);
if (remotePath.IsEmpty)
{
throw new ArgumentException("Invalid RemotePath");
}
if (localPath.IsEmpty || !localPath.IsRooted)
{
throw new ArgumentException("Invalid LocalPath");
}
if (!_diskProvider.FolderExists(localPath.FullPath))
{
throw new DirectoryNotFoundException("Can't add mount point directory that doesn't exist.");
}
if (existing.Exists(r => r.Host == mapping.Host && r.RemotePath == mapping.RemotePath))
{
throw new InvalidOperationException("RemotePath already mounted.");
}
}
public OsPath RemapRemoteToLocal(string host, OsPath remotePath)
{
if (remotePath.IsEmpty)
{
return remotePath;
}
foreach (var mapping in All())
{
if (host == mapping.Host && new OsPath(mapping.RemotePath).Contains(remotePath))
{
var localPath = new OsPath(mapping.LocalPath) + (remotePath - new OsPath(mapping.RemotePath));
return localPath;
}
}
return remotePath;
}
public OsPath RemapLocalToRemote(string host, OsPath localPath)
{
if (localPath.IsEmpty)
{
return localPath;
}
foreach (var mapping in All())
{
if (host == mapping.Host && new OsPath(mapping.LocalPath).Contains(localPath))
{
var remotePath = new OsPath(mapping.RemotePath) + (localPath - new OsPath(mapping.LocalPath));
return remotePath;
}
}
return localPath;
}
}
}