sync updates

pull/702/head
Luke Pulverenti 10 years ago
parent 016f2791d6
commit 28ffeb5121

@ -1,5 +1,7 @@
using MediaBrowser.Model.Sync; using MediaBrowser.Model.Sync;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -23,13 +25,22 @@ namespace MediaBrowser.Controller.Sync
/// <summary> /// <summary>
/// Transfers the item file. /// Transfers the item file.
/// </summary> /// </summary>
/// <param name="serverId">The server identifier.</param>
/// <param name="itemId">The item identifier.</param>
/// <param name="inputFile">The input file.</param> /// <param name="inputFile">The input file.</param>
/// <param name="pathParts">The path parts.</param> /// <param name="pathParts">The path parts.</param>
/// <param name="target">The target.</param> /// <param name="target">The target.</param>
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task TransferItemFile(string serverId, string itemId, string inputFile, string[] pathParts, SyncTarget target, CancellationToken cancellationToken); Task SendFile(string inputFile, string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken);
/// <summary>
/// Gets the file.
/// </summary>
/// <param name="pathParts">The path parts.</param>
/// <param name="target">The target.</param>
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;Stream&gt;.</returns>
Task<Stream> GetFile(string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken);
} }
} }

@ -1,5 +1,6 @@
using MediaBrowser.Model.Sync; using MediaBrowser.Model.Sync;
using System.Collections.Generic; using System;
using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -8,34 +9,24 @@ namespace MediaBrowser.Controller.Sync
public interface IServerSyncProvider : ISyncProvider public interface IServerSyncProvider : ISyncProvider
{ {
/// <summary> /// <summary>
/// Gets the server item ids. /// Transfers the file.
/// </summary>
/// <param name="serverId">The server identifier.</param>
/// <param name="target">The target.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;List&lt;System.String&gt;&gt;.</returns>
Task<List<string>> GetServerItemIds(string serverId, SyncTarget target, CancellationToken cancellationToken);
/// <summary>
/// Removes the item.
/// </summary> /// </summary>
/// <param name="serverId">The server identifier.</param> /// <param name="inputFile">The input file.</param>
/// <param name="itemId">The item identifier.</param> /// <param name="pathParts">The path parts.</param>
/// <param name="target">The target.</param> /// <param name="target">The target.</param>
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task DeleteItem(string serverId, string itemId, SyncTarget target, CancellationToken cancellationToken); Task SendFile(string inputFile, string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Transfers the file. /// Gets the file.
/// </summary> /// </summary>
/// <param name="serverId">The server identifier.</param>
/// <param name="itemId">The item identifier.</param>
/// <param name="inputFile">The input file.</param>
/// <param name="pathParts">The path parts.</param> /// <param name="pathParts">The path parts.</param>
/// <param name="target">The target.</param> /// <param name="target">The target.</param>
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns> /// <returns>Task&lt;Stream&gt;.</returns>
Task TransferItemFile(string serverId, string itemId, string inputFile, string[] pathParts, SyncTarget target, CancellationToken cancellationToken); Task<Stream> GetFile(string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken);
} }
} }

@ -773,7 +773,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{ {
try try
{ {
using (var file = new FileStream(path, FileMode.Open)) using (var file = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{ {
var detector = new CharsetDetector(); var detector = new CharsetDetector();
detector.Feed(file); detector.Feed(file);
@ -797,12 +797,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles
return null; return null;
} }
private static Encoding GetFileEncoding(string srcFile) private Encoding GetFileEncoding(string srcFile)
{ {
// *** Detect byte order mark if any - otherwise assume default // *** Detect byte order mark if any - otherwise assume default
var buffer = new byte[5]; var buffer = new byte[5];
using (var file = new FileStream(srcFile, FileMode.Open)) using (var file = _fileSystem.GetFileStream(srcFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{ {
file.Read(buffer, 0, 5); file.Read(buffer, 0, 5);
} }

@ -47,7 +47,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ImageMagickSharp.1.0.0.2\lib\net45\ImageMagickSharp.dll</HintPath> <HintPath>..\packages\ImageMagickSharp.1.0.0.3\lib\net45\ImageMagickSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="MediaBrowser.Naming, Version=1.0.5509.27636, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="MediaBrowser.Naming, Version=1.0.5509.27636, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>

@ -4,6 +4,7 @@ using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Sync; using MediaBrowser.Model.Sync;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -39,21 +40,18 @@ namespace MediaBrowser.Server.Implementations.Sync
return null; return null;
} }
public Task<List<string>> GetServerItemIds(string serverId, SyncTarget target, CancellationToken cancellationToken) public Task SendFile(string inputFile, string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
{ {
throw new NotImplementedException(); var provider = GetProvider(target);
}
public Task DeleteItem(string serverId, string itemId, SyncTarget target, CancellationToken cancellationToken) return provider.SendFile(inputFile, pathParts, target, progress, cancellationToken);
{
throw new NotImplementedException();
} }
public Task TransferItemFile(string serverId, string itemId, string inputFile, string[] pathParts, SyncTarget target, CancellationToken cancellationToken) public Task<Stream> GetFile(string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
{ {
var provider = GetProvider(target); var provider = GetProvider(target);
return provider.TransferItemFile(serverId, itemId, inputFile, pathParts, target, cancellationToken); return provider.GetFile(pathParts, target, progress, cancellationToken);
} }
} }
} }

@ -53,28 +53,28 @@ namespace MediaBrowser.Server.Implementations.Sync
SyncTarget target, SyncTarget target,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var localIds = await provider.GetServerItemIds(serverId, target, cancellationToken).ConfigureAwait(false); //var localIds = await provider.GetServerItemIds(serverId, target, cancellationToken).ConfigureAwait(false);
var result = await _syncManager.SyncData(new SyncDataRequest //var result = await _syncManager.SyncData(new SyncDataRequest
{ //{
TargetId = target.Id, // TargetId = target.Id,
LocalItemIds = localIds // LocalItemIds = localIds
}).ConfigureAwait(false); //}).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested(); //cancellationToken.ThrowIfCancellationRequested();
foreach (var itemIdToRemove in result.ItemIdsToRemove) //foreach (var itemIdToRemove in result.ItemIdsToRemove)
{ //{
try // try
{ // {
await RemoveItem(provider, serverId, itemIdToRemove, target, cancellationToken).ConfigureAwait(false); // await RemoveItem(provider, serverId, itemIdToRemove, target, cancellationToken).ConfigureAwait(false);
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
_logger.ErrorException("Error deleting item from sync target. Id: {0}", ex, itemIdToRemove); // _logger.ErrorException("Error deleting item from sync target. Id: {0}", ex, itemIdToRemove);
} // }
} //}
} }
private async Task GetNewMedia(IServerSyncProvider provider, private async Task GetNewMedia(IServerSyncProvider provider,
@ -83,7 +83,7 @@ namespace MediaBrowser.Server.Implementations.Sync
IProgress<double> progress, IProgress<double> progress,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var jobItems = await _syncManager.GetReadySyncItems(target.Id).ConfigureAwait(false); var jobItems = await _syncManager.GetReadySyncItems(target.Id).ConfigureAwait(false);
var numComplete = 0; var numComplete = 0;
double startingPercent = 0; double startingPercent = 0;
@ -138,8 +138,7 @@ namespace MediaBrowser.Server.Implementations.Sync
{ {
string[] pathParts = GetPathParts(serverId, libraryItem); string[] pathParts = GetPathParts(serverId, libraryItem);
await provider.TransferItemFile(serverId, libraryItem.Id, internalSyncJobItem.OutputPath, pathParts, target, cancellationToken) await SendFile(provider, internalSyncJobItem.OutputPath, pathParts, target, cancellationToken).ConfigureAwait(false);
.ConfigureAwait(false);
progress.Report(92); progress.Report(92);
@ -171,12 +170,19 @@ namespace MediaBrowser.Server.Implementations.Sync
SyncTarget target, SyncTarget target,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
return provider.DeleteItem(serverId, itemId, target, cancellationToken); return Task.FromResult(true);
//return provider.DeleteItem(serverId, itemId, target, cancellationToken);
} }
private string[] GetPathParts(string serverId, BaseItemDto item) private string[] GetPathParts(string serverId, BaseItemDto item)
{ {
return null; return null;
} }
private async Task SendFile(IServerSyncProvider provider, string inputPath, string[] path, SyncTarget target, CancellationToken cancellationToken)
{
await provider.SendFile(inputPath, path, target, new Progress<double>(), cancellationToken)
.ConfigureAwait(false);
}
} }
} }

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="ImageMagickSharp" version="1.0.0.2" targetFramework="net45" /> <package id="ImageMagickSharp" version="1.0.0.3" targetFramework="net45" />
<package id="MediaBrowser.Naming" version="1.0.0.32" targetFramework="net45" /> <package id="MediaBrowser.Naming" version="1.0.0.32" targetFramework="net45" />
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" /> <package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
<package id="morelinq" version="1.1.0" targetFramework="net45" /> <package id="morelinq" version="1.1.0" targetFramework="net45" />

@ -62,7 +62,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ImageMagickSharp.1.0.0.2\lib\net45\ImageMagickSharp.dll</HintPath> <HintPath>..\packages\ImageMagickSharp.1.0.0.3\lib\net45\ImageMagickSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="MediaBrowser.IsoMounter"> <Reference Include="MediaBrowser.IsoMounter">
<HintPath>..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll</HintPath> <HintPath>..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll</HintPath>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="ImageMagickSharp" version="1.0.0.2" targetFramework="net45" /> <package id="ImageMagickSharp" version="1.0.0.3" targetFramework="net45" />
<package id="MediaBrowser.IsoMounting" version="3.0.69" targetFramework="net45" /> <package id="MediaBrowser.IsoMounting" version="3.0.69" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" /> <package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" />
</packages> </packages>

@ -214,7 +214,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
} }
} }
using (var filestream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read)) using (var filestream = FileSystem.GetFileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
{ {
stream.CopyTo(filestream); stream.CopyTo(filestream);
} }

@ -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.576</version> <version>3.0.577</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.576" /> <dependency id="MediaBrowser.Common" version="3.0.577" />
<dependency id="NLog" version="3.2.0.0" /> <dependency id="NLog" version="3.2.0.0" />
<dependency id="SimpleInjector" version="2.7.0" /> <dependency id="SimpleInjector" version="2.7.0" />
</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.576</version> <version>3.0.577</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.576</version> <version>3.0.577</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.576</version> <version>3.0.577</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.576" /> <dependency id="MediaBrowser.Common" version="3.0.577" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>

Loading…
Cancel
Save