diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 8b45694d3..df65f256f 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -946,9 +946,13 @@ - - - + + + + + + + @@ -1122,6 +1126,7 @@ + diff --git a/src/NzbDrone.Core/TransferProviders/ITransferProvider.cs b/src/NzbDrone.Core/TransferProviders/ITransferProvider.cs new file mode 100644 index 000000000..c965badd7 --- /dev/null +++ b/src/NzbDrone.Core/TransferProviders/ITransferProvider.cs @@ -0,0 +1,14 @@ +using System; +using System.Linq; +using NzbDrone.Core.Download; +using NzbDrone.Core.ThingiProvider; + +namespace NzbDrone.Core.TransferProviders +{ + public interface ITransferProvider : IProvider, IVirtualDiskProvider + { + // Whether the TransferProvider is ready to be accessed. (Useful for external transfers that may not have finished yet) + bool IsAvailable(string downloadClientPath); + bool IsAvailable(DownloadClientItem item); + } +} diff --git a/src/NzbDrone.Core/TransferProviders/IVirtualDiskProvider.cs b/src/NzbDrone.Core/TransferProviders/IVirtualDiskProvider.cs new file mode 100644 index 000000000..9f23783f0 --- /dev/null +++ b/src/NzbDrone.Core/TransferProviders/IVirtualDiskProvider.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NzbDrone.Common.Disk; + +namespace NzbDrone.Core.TransferProviders +{ + // Represents the remote filesystem, or contents of rar, or ... etc. + // Any Move/Copy action should return an asynchroneous context representing the transfer in progress. So it can be shown in CDH / Activity->Queue. + public interface IVirtualDiskProvider // : IDiskProvider + { + // Copies file from the virtual filesystem to the actual one. + TransferTask CopyFile(string vfsSourcePath, string destinationPath); + } +} diff --git a/src/NzbDrone.Core/TransferProviders/Providers/CustomTransfer.cs b/src/NzbDrone.Core/TransferProviders/Providers/CustomTransfer.cs new file mode 100644 index 000000000..1227f6a4f --- /dev/null +++ b/src/NzbDrone.Core/TransferProviders/Providers/CustomTransfer.cs @@ -0,0 +1,43 @@ +using System; +using System.Linq; +using FluentValidation.Results; +using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Validation; + +namespace NzbDrone.Core.TransferProviders.Providers +{ + // Indicates that the files use some custom external transfer method. It's not guaranteed that the files are already available. + // The IsCopy flag indicates that the files are copied, not mounted. And thus can be safely moved during import, overriding the DownloadItem IsReadOnly flag. + // This TransferProvider should also have a mechanism for detecting whether the external transfer is in progress. But it should be 'deferred'. (see IsAvailable()) + + public class CustomTransferSettings : IProviderConfig + { + public string DownloadClientPath { get; set; } + public string LocalPath { get; set; } + + public bool IsCopy { get; set; } + + public NzbDroneValidationResult Validate() + { + throw new NotImplementedException(); + } + } + + public class CustomTransfer : TransferProviderBase + { + public override string Link + { + get { throw new NotImplementedException(); } + } + + public override string Name + { + get { throw new NotImplementedException(); } + } + + public override ValidationResult Test() + { + throw new NotImplementedException(); + } + } +} diff --git a/src/NzbDrone.Core/TransferProviders/Providers/MountTransfer.cs b/src/NzbDrone.Core/TransferProviders/Providers/MountTransfer.cs new file mode 100644 index 000000000..38a7252d0 --- /dev/null +++ b/src/NzbDrone.Core/TransferProviders/Providers/MountTransfer.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +using FluentValidation.Results; +using NzbDrone.Core.ThingiProvider; +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; } + public string MountPath { get; set; } + + public NzbDroneValidationResult Validate() + { + throw new NotImplementedException(); + } + } + + public class MountTransfer : TransferProviderBase + { + public override string Link + { + get { throw new NotImplementedException(); } + } + + public override string Name + { + get { throw new NotImplementedException(); } + } + + public override ValidationResult Test() + { + throw new NotImplementedException(); + } + } +} diff --git a/src/NzbDrone.Core/TransferProviders/TransferProviderFactory.cs b/src/NzbDrone.Core/TransferProviders/TransferProviderFactory.cs new file mode 100644 index 000000000..842549088 --- /dev/null +++ b/src/NzbDrone.Core/TransferProviders/TransferProviderFactory.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FluentValidation.Results; +using NLog; +using NzbDrone.Common.Composition; +using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Validation; + +namespace NzbDrone.Core.TransferProviders +{ + public class TransferProviderDefinition : ProviderDefinition + { + } + + public interface ITransferProviderFactory : IProviderFactory + { + } + + public abstract class TransferProviderBase : ITransferProvider where TSettings : IProviderConfig, new() + { + public abstract string Name { get; } + + public Type ConfigContract => typeof(TSettings); + + public virtual ProviderMessage Message => null; + + public IEnumerable DefaultDefinitions => new List(); + public ProviderDefinition Definition { get; set; } + public abstract ValidationResult Test(); + + public abstract string Link { get; } + + public virtual object RequestAction(string action, IDictionary query) { return null; } + } + + public interface ITransferProviderRepository : IProviderRepository + { + + } + + public class TransferProviderFactory : ProviderFactory, ITransferProviderFactory + { + public TransferProviderFactory(ITransferProviderRepository providerRepository, IEnumerable providers, IContainer container, IEventAggregator eventAggregator, Logger logger) + : base(providerRepository, providers, container, eventAggregator, logger) + { + } + } +} diff --git a/src/NzbDrone.Core/TransferProviders/TransferTask.cs b/src/NzbDrone.Core/TransferProviders/TransferTask.cs new file mode 100644 index 000000000..f306195d1 --- /dev/null +++ b/src/NzbDrone.Core/TransferProviders/TransferTask.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.TransferProviders +{ + public class TransferTask + { + // TODO: Progress reporting + + // TODO: Async task or waitable object so Importing can handle. + } +} diff --git a/src/NzbDrone.Core/RemotePathMappings/RemotePathMapping.cs b/src/NzbDrone.Core/TransferProviders/old/RemotePathMapping.cs similarity index 100% rename from src/NzbDrone.Core/RemotePathMappings/RemotePathMapping.cs rename to src/NzbDrone.Core/TransferProviders/old/RemotePathMapping.cs diff --git a/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingRepository.cs b/src/NzbDrone.Core/TransferProviders/old/RemotePathMappingRepository.cs similarity index 99% rename from src/NzbDrone.Core/RemotePathMappings/RemotePathMappingRepository.cs rename to src/NzbDrone.Core/TransferProviders/old/RemotePathMappingRepository.cs index a7df3c35a..bfdfc0000 100644 --- a/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingRepository.cs +++ b/src/NzbDrone.Core/TransferProviders/old/RemotePathMappingRepository.cs @@ -18,4 +18,4 @@ namespace NzbDrone.Core.RemotePathMappings protected override bool PublishModelEvents => true; } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs b/src/NzbDrone.Core/TransferProviders/old/RemotePathMappingService.cs similarity index 99% rename from src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs rename to src/NzbDrone.Core/TransferProviders/old/RemotePathMappingService.cs index d0d2e05be..4210ef0cb 100644 --- a/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs +++ b/src/NzbDrone.Core/TransferProviders/old/RemotePathMappingService.cs @@ -160,4 +160,4 @@ namespace NzbDrone.Core.RemotePathMappings return localPath; } } -} \ No newline at end of file +}