mirror of https://github.com/jellyfin/jellyfin.git
kick off sync right after creating job
This commit is contained in:
parent
d8d5dd4873
commit
87c23f145c
|
@ -1440,5 +1440,12 @@ namespace MediaBrowser.Model.ApiClient
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <returns>Task<SyncDataResponse>.</returns>
|
/// <returns>Task<SyncDataResponse>.</returns>
|
||||||
Task<SyncDataResponse> SyncData(SyncDataRequest request);
|
Task<SyncDataResponse> SyncData(SyncDataRequest request);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the synchronize job item file URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The identifier.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
string GetSyncJobItemFileUrl(string id);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -233,7 +233,8 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
using (var fs = _fileSystem.GetFileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, true))
|
using (var fs = _fileSystem.GetFileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, true))
|
||||||
{
|
{
|
||||||
await source.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
await source.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_config.Configuration.SaveMetadataHidden)
|
if (_config.Configuration.SaveMetadataHidden)
|
||||||
|
@ -244,6 +245,11 @@ namespace MediaBrowser.Providers.Manager
|
||||||
file.Attributes |= FileAttributes.Hidden;
|
file.Attributes |= FileAttributes.Hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
_logger.Error("Error saving image to {0}", ex, path);
|
||||||
|
throw new Exception(string.Format("Error saving image to {0}", path), ex);
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_libraryMonitor.ReportFileSystemChangeComplete(path, false);
|
_libraryMonitor.ReportFileSystemChangeComplete(path, false);
|
||||||
|
|
|
@ -909,14 +909,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
return obj as T;
|
return obj as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates an IBN item based on a given path
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <returns>Task{``0}.</returns>
|
|
||||||
/// <exception cref="System.IO.IOException">Path not created: + path</exception>
|
|
||||||
private T CreateItemByName<T>(string path, string name, Guid id)
|
private T CreateItemByName<T>(string path, string name, Guid id)
|
||||||
where T : BaseItem, new()
|
where T : BaseItem, new()
|
||||||
{
|
{
|
||||||
|
@ -941,8 +933,16 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
var isNew = false;
|
var isNew = false;
|
||||||
|
|
||||||
if (!fileInfo.Exists)
|
if (!fileInfo.Exists)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
fileInfo = Directory.CreateDirectory(path);
|
fileInfo = Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
_logger.Error("Error creating directory {0}", ex, path);
|
||||||
|
throw new Exception(string.Format("Error creating directory {0}", path), ex);
|
||||||
|
}
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,13 +326,17 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
Statuses = new List<SyncJobItemStatus> { SyncJobItemStatus.Queued, SyncJobItemStatus.Converting }
|
Statuses = new List<SyncJobItemStatus> { SyncJobItemStatus.Queued, SyncJobItemStatus.Converting }
|
||||||
});
|
});
|
||||||
|
|
||||||
var jobItems = result.Items;
|
await SyncJobItems(result.Items, true, progress, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SyncJobItems(SyncJobItem[] items, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
var index = 0;
|
var index = 0;
|
||||||
|
|
||||||
foreach (var item in jobItems)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
double percent = index;
|
double percent = index;
|
||||||
percent /= result.TotalRecordCount;
|
percent /= items.Length;
|
||||||
|
|
||||||
progress.Report(100 * percent);
|
progress.Report(100 * percent);
|
||||||
|
|
||||||
|
@ -341,7 +345,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
var innerProgress = new ActionableProgress<double>();
|
var innerProgress = new ActionableProgress<double>();
|
||||||
|
|
||||||
var job = _syncRepo.GetJob(item.JobId);
|
var job = _syncRepo.GetJob(item.JobId);
|
||||||
await ProcessJobItem(job, item, innerProgress, cancellationToken).ConfigureAwait(false);
|
await ProcessJobItem(job, item, enableConversion, innerProgress, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
job = _syncRepo.GetJob(item.JobId);
|
job = _syncRepo.GetJob(item.JobId);
|
||||||
await UpdateJobStatus(job).ConfigureAwait(false);
|
await UpdateJobStatus(job).ConfigureAwait(false);
|
||||||
|
@ -350,7 +354,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ProcessJobItem(SyncJob job, SyncJobItem jobItem, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task ProcessJobItem(SyncJob job, SyncJobItem jobItem, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var item = _libraryManager.GetItemById(jobItem.ItemId);
|
var item = _libraryManager.GetItemById(jobItem.ItemId);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
|
@ -378,12 +382,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
var video = item as Video;
|
var video = item as Video;
|
||||||
if (video != null)
|
if (video != null)
|
||||||
{
|
{
|
||||||
await Sync(jobItem, video, user, deviceProfile, progress, cancellationToken).ConfigureAwait(false);
|
await Sync(jobItem, video, user, deviceProfile, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item is Audio)
|
else if (item is Audio)
|
||||||
{
|
{
|
||||||
await Sync(jobItem, (Audio)item, user, deviceProfile, progress, cancellationToken).ConfigureAwait(false);
|
await Sync(jobItem, (Audio)item, user, deviceProfile, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item is Photo)
|
else if (item is Photo)
|
||||||
|
@ -397,7 +401,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Sync(SyncJobItem jobItem, Video item, User user, DeviceProfile profile, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task Sync(SyncJobItem jobItem, Video item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var options = new VideoOptions
|
var options = new VideoOptions
|
||||||
{
|
{
|
||||||
|
@ -415,6 +419,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
if (streamInfo.PlayMethod == PlayMethod.Transcode)
|
if (streamInfo.PlayMethod == PlayMethod.Transcode)
|
||||||
{
|
{
|
||||||
|
if (!enableConversion)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
jobItem.Status = SyncJobItemStatus.Converting;
|
jobItem.Status = SyncJobItemStatus.Converting;
|
||||||
jobItem.RequiresConversion = true;
|
jobItem.RequiresConversion = true;
|
||||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||||
|
@ -463,7 +472,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Sync(SyncJobItem jobItem, Audio item, User user, DeviceProfile profile, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task Sync(SyncJobItem jobItem, Audio item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var options = new AudioOptions
|
var options = new AudioOptions
|
||||||
{
|
{
|
||||||
|
@ -481,6 +490,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
if (streamInfo.PlayMethod == PlayMethod.Transcode)
|
if (streamInfo.PlayMethod == PlayMethod.Transcode)
|
||||||
{
|
{
|
||||||
|
if (!enableConversion)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
jobItem.Status = SyncJobItemStatus.Converting;
|
jobItem.Status = SyncJobItemStatus.Converting;
|
||||||
jobItem.RequiresConversion = true;
|
jobItem.RequiresConversion = true;
|
||||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||||
|
|
|
@ -23,6 +23,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Sync
|
namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
@ -127,6 +128,16 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
await processor.EnsureJobItems(job).ConfigureAwait(false);
|
await processor.EnsureJobItems(job).ConfigureAwait(false);
|
||||||
|
|
||||||
|
// If it already has a converting status then is must have been aborted during conversion
|
||||||
|
var jobItemsResult = _repo.GetJobItems(new SyncJobItemQuery
|
||||||
|
{
|
||||||
|
Statuses = new List<SyncJobItemStatus> { SyncJobItemStatus.Queued, SyncJobItemStatus.Converting },
|
||||||
|
JobId = jobId
|
||||||
|
});
|
||||||
|
|
||||||
|
await processor.SyncJobItems(jobItemsResult.Items, false, new Progress<double>(), CancellationToken.None)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return new SyncJobCreationResult
|
return new SyncJobCreationResult
|
||||||
{
|
{
|
||||||
Job = GetJob(jobId)
|
Job = GetJob(jobId)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Common.Internal</id>
|
<id>MediaBrowser.Common.Internal</id>
|
||||||
<version>3.0.540</version>
|
<version>3.0.541</version>
|
||||||
<title>MediaBrowser.Common.Internal</title>
|
<title>MediaBrowser.Common.Internal</title>
|
||||||
<authors>Luke</authors>
|
<authors>Luke</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
||||||
<copyright>Copyright © Media Browser 2013</copyright>
|
<copyright>Copyright © Media Browser 2013</copyright>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="MediaBrowser.Common" version="3.0.540" />
|
<dependency id="MediaBrowser.Common" version="3.0.541" />
|
||||||
<dependency id="NLog" version="3.1.0.0" />
|
<dependency id="NLog" version="3.1.0.0" />
|
||||||
<dependency id="SimpleInjector" version="2.6.1" />
|
<dependency id="SimpleInjector" version="2.6.1" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Common</id>
|
<id>MediaBrowser.Common</id>
|
||||||
<version>3.0.540</version>
|
<version>3.0.541</version>
|
||||||
<title>MediaBrowser.Common</title>
|
<title>MediaBrowser.Common</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Model.Signed</id>
|
<id>MediaBrowser.Model.Signed</id>
|
||||||
<version>3.0.540</version>
|
<version>3.0.541</version>
|
||||||
<title>MediaBrowser.Model - Signed Edition</title>
|
<title>MediaBrowser.Model - Signed Edition</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Server.Core</id>
|
<id>MediaBrowser.Server.Core</id>
|
||||||
<version>3.0.540</version>
|
<version>3.0.541</version>
|
||||||
<title>Media Browser.Server.Core</title>
|
<title>Media Browser.Server.Core</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||||
<copyright>Copyright © Media Browser 2013</copyright>
|
<copyright>Copyright © Media Browser 2013</copyright>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="MediaBrowser.Common" version="3.0.540" />
|
<dependency id="MediaBrowser.Common" version="3.0.541" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
|
|
Loading…
Reference in New Issue