sync updates

This commit is contained in:
Luke Pulverenti 2014-12-27 17:52:41 -05:00
parent 0840bb9ba2
commit 7bce2e04b6
36 changed files with 109 additions and 104 deletions

View File

@ -85,6 +85,13 @@ namespace MediaBrowser.Api.Sync
{
}
[Route("/Sync/Items/Ready", "GET", Summary = "Gets ready to download sync items.")]
public class GetReadySyncItems : IReturn<List<SyncedItem>>
{
[ApiMember(Name = "TargetId", Description = "TargetId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
public string TargetId { get; set; }
}
[Authenticated]
public class SyncService : BaseApiService
{
@ -207,5 +214,10 @@ namespace MediaBrowser.Api.Sync
await _syncManager.ReportOfflineAction(action).ConfigureAwait(false);
}
}
public object Get(GetReadySyncItems request)
{
return ToOptimizedResult(_syncManager.GetReadySyncItems(request.TargetId));
}
}
}

View File

@ -14,6 +14,7 @@ using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Library;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Users;
using System;
using System.Collections.Generic;
using System.IO;
@ -21,7 +22,6 @@ using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Controller.Entities
{

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Net;
using System;
using System.Threading;
using System.Threading.Tasks;

View File

@ -82,18 +82,18 @@ namespace MediaBrowser.Controller.Sync
/// <returns>SyncJobItem.</returns>
SyncJobItem GetJobItem(string id);
/// <summary>
/// Gets the job item information.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>SyncedItem.</returns>
SyncedItem GetJobItemInfo(string id);
/// <summary>
/// Reports the offline action.
/// </summary>
/// <param name="action">The action.</param>
/// <returns>Task.</returns>
Task ReportOfflineAction(UserAction action);
/// <summary>
/// Gets the ready synchronize items.
/// </summary>
/// <param name="targetId">The target identifier.</param>
/// <returns>List&lt;SyncedItem&gt;.</returns>
List<SyncedItem> GetReadySyncItems(string targetId);
}
}

View File

@ -7,7 +7,6 @@ using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;

View File

@ -165,6 +165,7 @@ namespace MediaBrowser.Model.Configuration
public string[] InsecureApps7 { get; set; }
public bool SaveMetadataHidden { get; set; }
public bool EnableWin8HttpListener { get; set; }
public NameValuePair[] ContentTypes { get; set; }
@ -180,6 +181,7 @@ namespace MediaBrowser.Model.Configuration
EnableDashboardResponseCaching = true;
EnableAutomaticRestart = true;
EnableWin8HttpListener = true;
EnableUPnP = true;

View File

@ -3,7 +3,7 @@ namespace MediaBrowser.Model.Sync
{
public class DeviceFileInfo
{
public string Path { get; set; }
public string[] Path { get; set; }
public string Name { get; set; }
}
}

View File

@ -18,7 +18,7 @@ namespace MediaBrowser.Model.Sync
/// Gets or sets the path.
/// </summary>
/// <value>The path.</value>
public string Path { get; set; }
public string[] Path { get; set; }
/// <summary>
/// Gets or sets the type of the image.
/// </summary>

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Connect;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Logging;
using System;

View File

@ -1,6 +1,5 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;

View File

@ -1,8 +1,6 @@
using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Implementations.Security;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;

View File

@ -4,7 +4,6 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Net;
namespace MediaBrowser.Server.Implementations.EntryPoints
{

View File

@ -1,7 +1,6 @@
using Funq;
using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Implementations.HttpServer.NetListener;
@ -205,10 +204,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
HostContext.Config.HandlerFactoryPath = ListenerRequest.GetHandlerPathIfAny(UrlPrefixes.First());
_listener = _supportsNativeWebSocket && NativeWebSocket.IsSupported
//? _listener = new HttpListenerServer(_logger, OnRequestReceived)
? _listener = new WebSocketSharpListener(_logger, OnRequestReceived)
: _listener = new WebSocketSharpListener(_logger, OnRequestReceived);
_listener = GetListener();
_listener.WebSocketHandler = WebSocketHandler;
_listener.ErrorHandler = ErrorHandler;
@ -217,6 +213,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
_listener.Start(UrlPrefixes);
}
private IHttpListener GetListener()
{
if (_supportsNativeWebSocket && NativeWebSocket.IsSupported)
{
return new HttpListenerServer(_logger, OnRequestReceived);
}
return new WebSocketSharpListener(_logger, OnRequestReceived);
}
private void WebSocketHandler(WebSocketConnectEventArgs args)
{
if (WebSocketConnected != null)

View File

@ -1,9 +1,8 @@
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Net;
using ServiceStack.Web;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.HttpServer
{

View File

@ -1,10 +1,9 @@
using System.Text;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Events;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
using System;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using WebSocketMessageType = MediaBrowser.Model.Net.WebSocketMessageType;

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
using ServiceStack;
using ServiceStack.Host.HttpListener;

View File

@ -1,12 +1,9 @@
using System.Text;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Events;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
using WebSocketMessageType = MediaBrowser.Model.Net.WebSocketMessageType;
using WebSocketState = MediaBrowser.Model.Net.WebSocketState;
namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
using ServiceStack;
using ServiceStack.Web;

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;

View File

@ -32,12 +32,12 @@ namespace MediaBrowser.Server.Implementations.Sync
private readonly IImageProcessor _imageProcessor;
private readonly ILogger _logger;
private readonly IUserManager _userManager;
private readonly IDtoService _dtoService;
private readonly Func<IDtoService> _dtoService;
private readonly IApplicationHost _appHost;
private ISyncProvider[] _providers = { };
public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, IDtoService dtoService, IApplicationHost appHost)
public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func<IDtoService> dtoService, IApplicationHost appHost)
{
_libraryManager = libraryManager;
_repo = repo;
@ -323,9 +323,8 @@ namespace MediaBrowser.Server.Implementations.Sync
return _repo.GetJobItems(query);
}
public SyncedItem GetJobItemInfo(string id)
private SyncedItem GetJobItemInfo(SyncJobItem jobItem)
{
var jobItem = GetJobItem(id);
var job = _repo.GetJob(jobItem.JobId);
var libraryItem = _libraryManager.GetItemById(jobItem.ItemId);
@ -338,7 +337,7 @@ namespace MediaBrowser.Server.Implementations.Sync
UserId = job.UserId
};
syncedItem.Item = _dtoService.GetBaseItemDto(libraryItem, new DtoOptions());
syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, new DtoOptions());
// TODO: this should be the media source of the transcoded output
syncedItem.Item.MediaSources = syncedItem.Item.MediaSources
@ -365,5 +364,16 @@ namespace MediaBrowser.Server.Implementations.Sync
{
return Task.FromResult(true);
}
public List<SyncedItem> GetReadySyncItems(string targetId)
{
var jobItemResult = GetJobItems(new SyncJobItemQuery
{
TargetId = targetId,
//Status = SyncJobItemStatus.Transferring
});
return jobItemResult.Items.Select(GetJobItemInfo).ToList();
}
}
}

View File

@ -36,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Sync
public async Task Initialize()
{
var dbFile = Path.Combine(_appPaths.DataPath, "sync7.db");
var dbFile = Path.Combine(_appPaths.DataPath, "sync8.db");
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
@ -298,7 +298,8 @@ namespace MediaBrowser.Server.Implementations.Sync
_deleteJobCommand.Transaction = transaction;
_deleteJobCommand.ExecuteNonQuery();
_deleteJobItemsCommand.GetParameter(index++).Value = new Guid(id);
index = 0;
_deleteJobItemsCommand.GetParameter(index++).Value = id;
_deleteJobItemsCommand.Transaction = transaction;
_deleteJobItemsCommand.ExecuteNonQuery();
@ -607,11 +608,16 @@ namespace MediaBrowser.Server.Implementations.Sync
var info = new SyncJobItem
{
Id = reader.GetGuid(0).ToString("N"),
ItemId = reader.GetString(1),
MediaSourceId = reader.GetString(2),
JobId = reader.GetString(3)
ItemId = reader.GetString(1)
};
if (!reader.IsDBNull(2))
{
info.MediaSourceId = reader.GetString(2);
}
info.JobId = reader.GetString(3);
if (!reader.IsDBNull(4))
{
info.OutputPath = reader.GetString(4);

View File

@ -1,6 +1,5 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.ApiClient;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;

View File

@ -67,7 +67,7 @@ namespace MediaBrowser.Server.Mac
return list;
}
public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
public void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory)
{
}

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.IsoMounter;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Mono.Networking;
@ -84,7 +83,7 @@ namespace MediaBrowser.Server.Mono.Native
return list;
}
public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
public void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory)
{
}

View File

@ -1,6 +1,5 @@
using MediaBrowser.Common.Implementations.Networking;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;

View File

@ -224,7 +224,7 @@ namespace MediaBrowser.Server.Startup.Common
private readonly StartupOptions _startupOptions;
private readonly string _remotePackageName;
private readonly bool _supportsNativeWebSocket;
private bool _supportsNativeWebSocket;
internal INativeApp NativeApp { get; set; }
@ -454,6 +454,18 @@ namespace MediaBrowser.Server.Startup.Common
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
if (IsFirstRun)
{
ServerConfigurationManager.Configuration.EnableWin8HttpListener = false;
ServerConfigurationManager.SaveConfiguration();
_supportsNativeWebSocket = false;
}
if (!ServerConfigurationManager.Configuration.EnableWin8HttpListener)
{
_supportsNativeWebSocket = false;
}
HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", _supportsNativeWebSocket);
RegisterSingleInstance(HttpServer, false);
progress.Report(10);
@ -470,7 +482,7 @@ namespace MediaBrowser.Server.Startup.Common
ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder);
RegisterSingleInstance(ImageProcessor);
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, DtoService, this);
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this);
RegisterSingleInstance(SyncManager);
DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this);
@ -735,7 +747,7 @@ namespace MediaBrowser.Server.Startup.Common
ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
StartServer(true);
StartServer();
LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
GetExports<IVirtualFolderCreator>(),
@ -773,8 +785,7 @@ namespace MediaBrowser.Server.Startup.Common
/// <summary>
/// Starts the server.
/// </summary>
/// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param>
private void StartServer(bool retryOnFailure)
private void StartServer()
{
try
{
@ -784,16 +795,7 @@ namespace MediaBrowser.Server.Startup.Common
{
Logger.ErrorException("Error starting http server", ex);
if (retryOnFailure)
{
RegisterServerWithAdministratorAccess();
StartServer(false);
}
else
{
throw;
}
throw;
}
}
@ -1070,9 +1072,8 @@ namespace MediaBrowser.Server.Startup.Common
try
{
NativeApp.AuthorizeServer(
ServerConfigurationManager.Configuration.HttpServerPortNumber,
HttpServerUrlPrefixes.First(),
UdpServerEntryPoint.PortNumber,
ServerConfigurationManager.Configuration.HttpServerPortNumber,
ConfigurationManager.CommonApplicationPaths.TempDirectory);
}
catch (Exception ex)

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
using System.Collections.Generic;
using System.Reflection;
@ -17,11 +16,10 @@ namespace MediaBrowser.Server.Startup.Common
/// <summary>
/// Authorizes the server.
/// </summary>
/// <param name="httpServerPort">The HTTP server port.</param>
/// <param name="httpServerUrlPrefix">The HTTP server URL prefix.</param>
/// <param name="udpPort">The UDP port.</param>
/// <param name="httpServerPort">The HTTP server port.</param>
/// <param name="tempDirectory">The temporary directory.</param>
void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory);
void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory);
/// <summary>
/// Gets the environment.

View File

@ -1,21 +1,15 @@
rem %1 = http server port
rem %2 = http server url
rem %3 = udp server port
rem %1 = udp server port
rem %2 = http server port
if [%1]==[] GOTO DONE
netsh advfirewall firewall delete rule name="Port %1" protocol=TCP localport=%1
netsh advfirewall firewall add rule name="Port %1" dir=in action=allow protocol=TCP localport=%1
netsh advfirewall firewall delete rule name="Port %1" protocol=UDP localport=%1
netsh advfirewall firewall add rule name="Port %1" dir=in action=allow protocol=UDP localport=%1
if [%2]==[] GOTO DONE
netsh http del urlacl url="%2" user="NT AUTHORITY\Authenticated Users"
netsh http add urlacl url="%2" user="NT AUTHORITY\Authenticated Users"
if [%3]==[] GOTO DONE
netsh advfirewall firewall delete rule name="Port %3" protocol=UDP localport=%3
netsh advfirewall firewall add rule name="Port %3" dir=in action=allow protocol=UDP localport=%3
netsh advfirewall firewall delete rule name="Port %2" protocol=TCP localport=%2
netsh advfirewall firewall add rule name="Port %2" dir=in action=allow protocol=TCP localport=%2
:DONE

View File

@ -13,11 +13,10 @@ namespace MediaBrowser.ServerApplication.Native
/// <summary>
/// Authorizes the server.
/// </summary>
/// <param name="httpServerPort">The HTTP server port.</param>
/// <param name="httpServerUrlPrefix">The HTTP server URL prefix.</param>
/// <param name="udpPort">The UDP port.</param>
/// <param name="httpServerPort">The HTTP server port.</param>
/// <param name="tempDirectory">The temp directory.</param>
public static void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
public static void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory)
{
Directory.CreateDirectory(tempDirectory);
@ -37,9 +36,7 @@ namespace MediaBrowser.ServerApplication.Native
{
FileName = tmpFile,
Arguments = string.Format("{0} {1} {2}", httpServerPort,
httpServerUrlPrefix,
udpPort),
Arguments = string.Format("{0} {1}", udpPort, httpServerPort),
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.IsoMounter;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Startup.Common;
@ -22,9 +21,9 @@ namespace MediaBrowser.ServerApplication.Native
return list;
}
public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
public void AuthorizeServer(int httpServerPort, int udpPort, string tempDirectory)
{
ServerAuthorization.AuthorizeServer(httpServerPort, httpServerUrlPrefix, udpPort, tempDirectory);
ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, tempDirectory);
}
public NativeEnvironment Environment

View File

@ -1,6 +1,5 @@
using MediaBrowser.Common.Implementations.Networking;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.532</version>
<version>3.0.533</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<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>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.532" />
<dependency id="MediaBrowser.Common" version="3.0.533" />
<dependency id="NLog" version="3.1.0.0" />
<dependency id="SimpleInjector" version="2.6.1" />
<dependency id="sharpcompress" version="0.10.2" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.532</version>
<version>3.0.533</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Model.Signed</id>
<version>3.0.532</version>
<version>3.0.533</version>
<title>MediaBrowser.Model - Signed Edition</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.532</version>
<version>3.0.533</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.532" />
<dependency id="MediaBrowser.Common" version="3.0.533" />
</dependencies>
</metadata>
<files>