mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
sync updates
This commit is contained in:
parent
daf2c28eb7
commit
19ecd450b8
@ -79,6 +79,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
|||||||
QueueScheduledTask<T>(options);
|
QueueScheduledTask<T>(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelIfRunningAndQueue<T>()
|
||||||
|
where T : IScheduledTask
|
||||||
|
{
|
||||||
|
CancelIfRunningAndQueue<T>(new TaskExecutionOptions());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancels if running
|
/// Cancels if running
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -103,6 +109,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
|||||||
QueueScheduledTask(scheduledTask, options);
|
QueueScheduledTask(scheduledTask, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void QueueScheduledTask<T>()
|
||||||
|
where T : IScheduledTask
|
||||||
|
{
|
||||||
|
QueueScheduledTask<T>(new TaskExecutionOptions());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Queues the scheduled task.
|
/// Queues the scheduled task.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -59,6 +59,11 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Stream OpenFile(string path)
|
||||||
|
{
|
||||||
|
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deserializes from file.
|
/// Deserializes from file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -78,7 +83,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
|||||||
throw new ArgumentNullException("file");
|
throw new ArgumentNullException("file");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (Stream stream = File.OpenRead(file))
|
using (Stream stream = OpenFile(file))
|
||||||
{
|
{
|
||||||
return DeserializeFromStream(stream, type);
|
return DeserializeFromStream(stream, type);
|
||||||
}
|
}
|
||||||
@ -99,7 +104,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
|||||||
throw new ArgumentNullException("file");
|
throw new ArgumentNullException("file");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (Stream stream = File.OpenRead(file))
|
using (Stream stream = OpenFile(file))
|
||||||
{
|
{
|
||||||
return DeserializeFromStream<T>(stream);
|
return DeserializeFromStream<T>(stream);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,14 @@ namespace MediaBrowser.Common.ScheduledTasks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="options">Task options.</param>
|
/// <param name="options">Task options.</param>
|
||||||
void CancelIfRunningAndQueue<T>(TaskExecutionOptions options = null)
|
void CancelIfRunningAndQueue<T>(TaskExecutionOptions options)
|
||||||
|
where T : IScheduledTask;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cancels if running and queue.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
void CancelIfRunningAndQueue<T>()
|
||||||
where T : IScheduledTask;
|
where T : IScheduledTask;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -33,7 +40,14 @@ namespace MediaBrowser.Common.ScheduledTasks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="options">Task options.</param>
|
/// <param name="options">Task options.</param>
|
||||||
void QueueScheduledTask<T>(TaskExecutionOptions options = null)
|
void QueueScheduledTask<T>(TaskExecutionOptions options)
|
||||||
|
where T : IScheduledTask;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Queues the scheduled task.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
void QueueScheduledTask<T>()
|
||||||
where T : IScheduledTask;
|
where T : IScheduledTask;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -308,12 +308,13 @@
|
|||||||
<Compile Include="Sync\IHasSyncProfile.cs" />
|
<Compile Include="Sync\IHasSyncProfile.cs" />
|
||||||
<Compile Include="Sync\MediaSync.cs" />
|
<Compile Include="Sync\MediaSync.cs" />
|
||||||
<Compile Include="Sync\MultiProviderSync.cs" />
|
<Compile Include="Sync\MultiProviderSync.cs" />
|
||||||
|
<Compile Include="Sync\ServerSyncScheduledTask.cs" />
|
||||||
<Compile Include="Sync\SyncRegistrationInfo.cs" />
|
<Compile Include="Sync\SyncRegistrationInfo.cs" />
|
||||||
<Compile Include="Sync\SyncConfig.cs" />
|
<Compile Include="Sync\SyncConfig.cs" />
|
||||||
<Compile Include="Sync\SyncJobProcessor.cs" />
|
<Compile Include="Sync\SyncJobProcessor.cs" />
|
||||||
<Compile Include="Sync\SyncManager.cs" />
|
<Compile Include="Sync\SyncManager.cs" />
|
||||||
<Compile Include="Sync\SyncRepository.cs" />
|
<Compile Include="Sync\SyncRepository.cs" />
|
||||||
<Compile Include="Sync\SyncScheduledTask.cs" />
|
<Compile Include="Sync\SyncConvertScheduledTask.cs" />
|
||||||
<Compile Include="Themes\AppThemeManager.cs" />
|
<Compile Include="Themes\AppThemeManager.cs" />
|
||||||
<Compile Include="TV\TVSeriesManager.cs" />
|
<Compile Include="TV\TVSeriesManager.cs" />
|
||||||
<Compile Include="Udp\UdpMessageReceivedEventArgs.cs" />
|
<Compile Include="Udp\UdpMessageReceivedEventArgs.cs" />
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
using MediaBrowser.Common.IO;
|
||||||
|
using MediaBrowser.Common.ScheduledTasks;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Sync;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
{
|
||||||
|
class ServerSyncScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
|
||||||
|
{
|
||||||
|
private readonly ISyncManager _syncManager;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly IServerApplicationHost _appHost;
|
||||||
|
|
||||||
|
public ServerSyncScheduledTask(ISyncManager syncManager, ILogger logger, IFileSystem fileSystem, IServerApplicationHost appHost)
|
||||||
|
{
|
||||||
|
_syncManager = syncManager;
|
||||||
|
_logger = logger;
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_appHost = appHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "Cloud & Folder Sync"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get { return "Sync media to the cloud"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Category
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Sync";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
||||||
|
{
|
||||||
|
return new MultiProviderSync(_syncManager, _appHost, _logger, _fileSystem)
|
||||||
|
.Sync(ServerSyncProviders, progress, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<IServerSyncProvider> ServerSyncProviders
|
||||||
|
{
|
||||||
|
get { return ((SyncManager)_syncManager).ServerSyncProviders; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
|
||||||
|
{
|
||||||
|
return new ITaskTrigger[]
|
||||||
|
{
|
||||||
|
new IntervalTrigger { Interval = TimeSpan.FromHours(6) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsHidden
|
||||||
|
{
|
||||||
|
get { return !IsEnabled; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEnabled
|
||||||
|
{
|
||||||
|
get { return ServerSyncProviders.Any(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Key
|
||||||
|
{
|
||||||
|
get { return "ServerSync"; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Sync
|
namespace MediaBrowser.Server.Implementations.Sync
|
||||||
{
|
{
|
||||||
public class SyncScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
|
public class SyncConvertScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
|
||||||
{
|
{
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly ISyncRepository _syncRepo;
|
private readonly ISyncRepository _syncRepo;
|
||||||
@ -26,7 +26,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
private readonly IConfigurationManager _config;
|
private readonly IConfigurationManager _config;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
public SyncScheduledTask(ILibraryManager libraryManager, ISyncRepository syncRepo, ISyncManager syncManager, ILogger logger, IUserManager userManager, ITVSeriesManager tvSeriesManager, IMediaEncoder mediaEncoder, ISubtitleEncoder subtitleEncoder, IConfigurationManager config, IFileSystem fileSystem)
|
public SyncConvertScheduledTask(ILibraryManager libraryManager, ISyncRepository syncRepo, ISyncManager syncManager, ILogger logger, IUserManager userManager, ITVSeriesManager tvSeriesManager, IMediaEncoder mediaEncoder, ISubtitleEncoder subtitleEncoder, IConfigurationManager config, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_syncRepo = syncRepo;
|
_syncRepo = syncRepo;
|
@ -79,6 +79,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
_providers = providers.ToArray();
|
_providers = providers.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<IServerSyncProvider> ServerSyncProviders
|
||||||
|
{
|
||||||
|
get { return _providers.OfType<IServerSyncProvider>(); }
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<SyncJobCreationResult> CreateJob(SyncJobRequest request)
|
public async Task<SyncJobCreationResult> CreateJob(SyncJobRequest request)
|
||||||
{
|
{
|
||||||
var processor = GetSyncJobProcessor();
|
var processor = GetSyncJobProcessor();
|
||||||
@ -438,8 +443,9 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
return target.Id;
|
return target.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
var providerId = GetSyncProviderId(provider);
|
return target.Id;
|
||||||
return (providerId + "-" + target.Id).GetMD5().ToString("N");
|
//var providerId = GetSyncProviderId(provider);
|
||||||
|
//return (providerId + "-" + target.Id).GetMD5().ToString("N");
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetSyncProviderId(ISyncProvider provider)
|
private string GetSyncProviderId(ISyncProvider provider)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user