Mockups of Transfer Providers.

This commit is contained in:
Taloth Saldono 2017-11-06 22:08:41 +01:00
parent 0553a39a02
commit 2a0a4cfb6d
10 changed files with 187 additions and 5 deletions

View File

@ -946,9 +946,13 @@
<Compile Include="ProgressMessaging\ProgressMessageContext.cs" />
<Compile Include="Qualities\QualitySource.cs" />
<Compile Include="Qualities\Revision.cs" />
<Compile Include="RemotePathMappings\RemotePathMapping.cs" />
<Compile Include="RemotePathMappings\RemotePathMappingRepository.cs" />
<Compile Include="RemotePathMappings\RemotePathMappingService.cs" />
<Compile Include="TransferProviders\CustomTransferProvider.cs" />
<Compile Include="TransferProviders\ITransferProvider.cs" />
<Compile Include="TransferProviders\IVirtualDiskProvider.cs" />
<Compile Include="TransferProviders\MountTransferProvider.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">
@ -1122,6 +1126,7 @@
<Compile Include="ThingiProvider\Status\ProviderStatusRepository.cs" />
<Compile Include="ThingiProvider\Status\ProviderStatusServiceBase.cs" />
<Compile Include="TinyTwitter.cs" />
<Compile Include="TransferProviders\TransferProviderFactory.cs" />
<Compile Include="Tv\Actor.cs" />
<Compile Include="Tv\AddSeriesOptions.cs" />
<Compile Include="Tv\AddSeriesService.cs" />

View File

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

View File

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

View File

@ -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<CustomTransferSettings>
{
public override string Link
{
get { throw new NotImplementedException(); }
}
public override string Name
{
get { throw new NotImplementedException(); }
}
public override ValidationResult Test()
{
throw new NotImplementedException();
}
}
}

View File

@ -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<MountSettings>
{
public override string Link
{
get { throw new NotImplementedException(); }
}
public override string Name
{
get { throw new NotImplementedException(); }
}
public override ValidationResult Test()
{
throw new NotImplementedException();
}
}
}

View File

@ -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<ITransferProvider, TransferProviderDefinition>
{
}
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 IEnumerable<ProviderDefinition> DefaultDefinitions => new List<ProviderDefinition>();
public ProviderDefinition Definition { get; set; }
public abstract ValidationResult Test();
public abstract string Link { get; }
public virtual object RequestAction(string action, IDictionary<string, string> query) { return null; }
}
public interface ITransferProviderRepository : IProviderRepository<TransferProviderDefinition>
{
}
public class TransferProviderFactory : ProviderFactory<ITransferProvider, TransferProviderDefinition>, ITransferProviderFactory
{
public TransferProviderFactory(ITransferProviderRepository providerRepository, IEnumerable<ITransferProvider> providers, IContainer container, IEventAggregator eventAggregator, Logger logger)
: base(providerRepository, providers, container, eventAggregator, logger)
{
}
}
}

View File

@ -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.
}
}

View File

@ -18,4 +18,4 @@ namespace NzbDrone.Core.RemotePathMappings
protected override bool PublishModelEvents => true;
}
}
}

View File

@ -160,4 +160,4 @@ namespace NzbDrone.Core.RemotePathMappings
return localPath;
}
}
}
}