Skip to content

Commit

Permalink
unbatch media #18
Browse files Browse the repository at this point in the history
no need to batch upmedia saves, and it causes issues anyway.
  • Loading branch information
Kevin Jump committed Sep 18, 2019
1 parent 4ad2fb0 commit 1bf129a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 5 additions & 6 deletions uSync8.ContentEdition/Serializers/MediaSerializer.cs
Expand Up @@ -88,14 +88,13 @@ public override SyncAttempt<IMedia> DeserializeSecondPass(IMedia item, XElement
// ?
}

if (!flags.HasFlag(SerializerFlags.DoNotSave)) {

var attempt = mediaService.Save(item);
if (!attempt.Success)
return SyncAttempt<IMedia>.Fail(item.Name, ChangeType.Fail, "");
}
var attempt = mediaService.Save(item);
if (!attempt.Success)
return SyncAttempt<IMedia>.Fail(item.Name, ChangeType.Fail, "");

return SyncAttempt<IMedia>.Succeed(item.Name, ChangeType.Import);
// we return no-change so we don't trigger the second save
return SyncAttempt<IMedia>.Succeed(item.Name, ChangeType.NoChange );


}
Expand Down
7 changes: 5 additions & 2 deletions uSync8.Core/Serialization/Serializers/DataTypeSerializer.cs
Expand Up @@ -201,10 +201,13 @@ protected override IEnumerable<EntityContainer> FindContainers(string folder, in
=> dataTypeService.CreateContainer(parentId, name);

protected override void SaveItem(IDataType item)
=> dataTypeService.Save(item.AsEnumerableOfOne(), -1, false);
=> dataTypeService.Save(item);

public override void Save(IEnumerable<IDataType> items)
=> dataTypeService.Save(items, -1, false);
{
// if we don't trigger then the cache doesn't get updated :(
dataTypeService.Save(items);
}

protected override void SaveContainer(EntityContainer container)
=> dataTypeService.SaveContainer(container);
Expand Down

0 comments on commit 1bf129a

Please sign in to comment.