sync fixes

This commit is contained in:
Luke Pulverenti 2015-03-25 19:13:15 -04:00
parent 5c597be7de
commit 9f191a3598
3 changed files with 30 additions and 6 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Model.Dto;
using System;
using System.Collections.Generic;
namespace MediaBrowser.Model.Sync
@ -16,6 +17,16 @@ namespace MediaBrowser.Model.Sync
/// <value>The synchronize job identifier.</value>
public string SyncJobId { get; set; }
/// <summary>
/// Gets or sets the name of the synchronize job.
/// </summary>
/// <value>The name of the synchronize job.</value>
public string SyncJobName { get; set; }
/// <summary>
/// Gets or sets the synchronize job date created.
/// </summary>
/// <value>The synchronize job date created.</value>
public DateTime SyncJobDateCreated { get; set; }
/// <summary>
/// Gets or sets the synchronize job item identifier.
/// </summary>
/// <value>The synchronize job item identifier.</value>

View File

@ -143,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Sync
var fileTransferProgress = new ActionableProgress<double>();
fileTransferProgress.RegisterAction(pct => progress.Report(pct * .92));
var localItem = CreateLocalItem(provider, jobItem.SyncJobId, jobItem.SyncJobItemId, target, libraryItem, serverId, jobItem.OriginalFileName);
var localItem = CreateLocalItem(provider, jobItem, target, libraryItem, serverId, jobItem.OriginalFileName);
await _syncManager.ReportSyncJobItemTransferBeginning(internalSyncJobItem.Id);
@ -232,6 +232,8 @@ namespace MediaBrowser.Server.Implementations.Sync
foreach (var file in files)
{
_logger.Debug("Removing {0} from {1}.", file.Path, target.Name);
await provider.DeleteFile(file.Path, target, cancellationToken).ConfigureAwait(false);
}
@ -263,9 +265,9 @@ namespace MediaBrowser.Server.Implementations.Sync
}
}
public LocalItem CreateLocalItem(IServerSyncProvider provider, string syncJobId, string syncJobItemId, SyncTarget target, BaseItemDto libraryItem, string serverId, string originalFileName)
public LocalItem CreateLocalItem(IServerSyncProvider provider, SyncedItem syncedItem, SyncTarget target, BaseItemDto libraryItem, string serverId, string originalFileName)
{
var path = GetDirectoryPath(provider, syncJobId, libraryItem, serverId);
var path = GetDirectoryPath(provider, syncedItem, libraryItem, serverId);
path.Add(GetLocalFileName(provider, libraryItem, originalFileName));
var localPath = provider.GetFullPath(path, target);
@ -282,16 +284,25 @@ namespace MediaBrowser.Server.Implementations.Sync
ItemId = libraryItem.Id,
ServerId = serverId,
LocalPath = localPath,
Id = GetLocalId(syncJobItemId, libraryItem.Id)
Id = GetLocalId(syncedItem.SyncJobItemId, libraryItem.Id)
};
}
private List<string> GetDirectoryPath(IServerSyncProvider provider, string syncJobId, BaseItemDto item, string serverId)
private string GetSyncJobFolderName(SyncedItem syncedItem, IServerSyncProvider provider)
{
var name = syncedItem.SyncJobName + syncedItem.SyncJobDateCreated.ToLocalTime().ToString("g");
name = GetValidFilename(provider, name);
return name;
}
private List<string> GetDirectoryPath(IServerSyncProvider provider, SyncedItem syncedItem, BaseItemDto item, string serverId)
{
var parts = new List<string>
{
serverId,
syncJobId
GetSyncJobFolderName(syncedItem, provider)
};
if (item.IsType("episode"))

View File

@ -646,6 +646,8 @@ namespace MediaBrowser.Server.Implementations.Sync
SyncJobItemId = jobItem.Id,
ServerId = _appHost.SystemId,
UserId = job.UserId,
SyncJobName = job.Name,
SyncJobDateCreated = job.DateCreated,
AdditionalFiles = jobItem.AdditionalFiles.Select(i => new ItemFileInfo
{
ImageType = i.ImageType,