Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions uSync.Core/Serialization/Serializers/ContentSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,8 @@ public int DeserializeWriterInfo(IContent item, XElement node, SyncSerializerOpt
public override async Task<SyncAttempt<IContent>> DeserializeSecondPassAsync(IContent item, XElement node, SyncSerializerOptions options)
{
var details = new List<uSyncChange>();
// move trashed state to second pass, as the item needs an Id for the relation to work.
details.AddNotNull(await DeserializeTrashed(node, item, Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias));

// move sort to second pass, as if we attempt to set this
// on a brand new item, it doesn't get set.
// doing it on second pass ensures it gets set on the item
// after it has been saved by umbraco.
if (!options.GetSetting<bool>(
uSyncConstants.DefaultSettings.IgnoreSortOrder,
uSyncConstants.DefaultSettings.IgnoreSortOrder_Default))
{
var sortOrder = node.Element(uSyncConstants.Xml.Info)?.Element(uSyncConstants.Xml.SortOrder).ValueOrDefault(-1) ?? -1;
details.AddNotNull(HandleSortOrder(item, sortOrder));
}

details.AddRange(await this.DeserializeSecondPassSharedAsync(item, node, options));

var changes = await DeserializeSchedulesAsync(item, node, options);
if (changes.Count != 0)
Expand Down
26 changes: 26 additions & 0 deletions uSync.Core/Serialization/Serializers/ContentSerializerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,32 @@ protected async Task<Attempt<List<uSyncChange>, string>> DeserializePropertiesAs
return Attempt.SucceedWithStatus(errors, changes);
}

/// <summary>
/// things most 'IContentBase' serializers need (ones that have trash anyway).
Comment thread
KevinJump marked this conversation as resolved.
Outdated
/// </summary>
protected async Task<List<uSyncChange>> DeserializeSecondPassSharedAsync(TObject item, XElement node, SyncSerializerOptions options)
{
var details = new List<uSyncChange>();

// move trashed state to second pass, as the item needs an Id for the relation to work.
details.AddNotNull(await DeserializeTrashed(node, item, Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias));
Comment thread
KevinJump marked this conversation as resolved.
Outdated

// move sort to second pass, as if we attempt to set this
// on a brand new item, it doesn't get set.
// doing it on second pass ensures it gets set on the item
// after it has been saved by umbraco.
if (!options.GetSetting<bool>(
uSyncConstants.DefaultSettings.IgnoreSortOrder,
uSyncConstants.DefaultSettings.IgnoreSortOrder_Default))
{
var sortOrder = node.Element(uSyncConstants.Xml.Info)?.Element(uSyncConstants.Xml.SortOrder).ValueOrDefault(-1) ?? -1;
details.AddNotNull(HandleSortOrder(item, sortOrder));
}

return details;
}


/// <summary>
/// compares to object values to see if they are the same.
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions uSync.Core/Serialization/Serializers/MediaSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ protected override async Task<SyncAttempt<IMedia>> DeserializeCoreAsync(XElement

public override async Task<SyncAttempt<IMedia>> DeserializeSecondPassAsync(IMedia item, XElement node, SyncSerializerOptions options)
{
var details = new List<uSyncChange>();
details.AddNotNull(await DeserializeTrashed(node, item, Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias));
var details = await DeserializeSecondPassSharedAsync(item, node, options);

return SyncAttempt<IMedia>.Succeed(item.Name ?? item.Id.ToString(), item,
details.Count == 0 ? ChangeType.NoChange : ChangeType.Import, details);
Expand Down