Skip to content

Commit

Permalink
Fix #108 - Parent nodes can be null when items are put in the trash.
Browse files Browse the repository at this point in the history
fixes the find methods, which are called to get a parent item, but when you trash a item - its parent is set to null 😦
  • Loading branch information
Kevin Jump committed May 23, 2020
1 parent 4d2b9e3 commit eecb6c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 7 additions & 3 deletions uSync8.ContentEdition/Serializers/ContentSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,13 @@ protected override IContent CreateItem(string alias, ITreeEntity parent, string
protected override IContent FindItem(int id)
{
var item = contentService.GetById(id);
if (!this.nameCache.ContainsKey(id))
this.nameCache[id] = new Tuple<Guid, string>(item.Key, item.Name);
return item;
if (item != null)
{
if (!this.nameCache.ContainsKey(id))
this.nameCache[id] = new Tuple<Guid, string>(item.Key, item.Name);
return item;
}
return null;
}

protected override IContent FindItem(Guid key)
Expand Down
11 changes: 8 additions & 3 deletions uSync8.ContentEdition/Serializers/MediaSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography;
using System.Xml.Linq;

Expand Down Expand Up @@ -182,9 +183,13 @@ protected override IMedia CreateItem(string alias, ITreeEntity parent, string it
protected override IMedia FindItem(int id)
{
var item = mediaService.GetById(id);
if (!this.nameCache.ContainsKey(id))
this.nameCache[id] = new Tuple<Guid, string>(item.Key, item.Name);
return item;
if (item != null)
{
if (!this.nameCache.ContainsKey(id))
this.nameCache[id] = new Tuple<Guid, string>(item.Key, item.Name);
return item;
}
return null;
}


Expand Down

0 comments on commit eecb6c3

Please sign in to comment.