Skip to content

Commit

Permalink
Fix: when export has multiple cultures / non-culture values - continu…
Browse files Browse the repository at this point in the history
…e to next don't just break.
  • Loading branch information
Kevin Jump committed Aug 7, 2020
1 parent 6ccf84e commit 7653143
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static Attempt<string> ToAttempt(this PublishResult result)
errorMessage = string.Join(": ", result.EventMessages.GetAll().Select(x => $"{x.Category}: {x.Message}"));
}

return Attempt.Fail($"Failed: {errorMessage}");
return Attempt.Fail($"Publish Failed {result.Result} {errorMessage}");
}
}
}
7 changes: 6 additions & 1 deletion uSync8.ContentEdition/Serializers/ContentSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,12 @@ private Attempt<string> PublishItem(IContent item, IDictionary<string, uSyncCont
var result = contentService.SaveAndPublish(item, publishedCultures);

// if this fails, we return the result
if (!result.Success) return result.ToAttempt();
if (!result.Success)
{
var messages = string.Join(",", result.EventMessages.GetAll().Select(x => $"{x.Category} {x.MessageType} {x.Message}"));
logger.Error<ContentSerializer>("Failed to Publish {result} {messages}", result.Result, messages);
return result.ToAttempt();
}

// if its published here it's also saved, so we can skip the save below.
hasBeenSaved = true;
Expand Down
10 changes: 5 additions & 5 deletions uSync8.ContentEdition/Serializers/ContentSerializerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ protected Attempt<TObject, String> DeserializeProperties(TObject item, XElement
// this culture is not the default for the site, so don't use it to
// set the single language value.
logger.Warn(serializerType, "Culture {culture} in file, but is not default so not being used", culture);
break;
continue;
}
logger.Warn(serializerType, "Cannot set value on culture {culture} because it is not avalible for this property - value in default language will be used", culture);
culture = string.Empty;
Expand All @@ -443,7 +443,7 @@ protected Attempt<TObject, String> DeserializeProperties(TObject item, XElement
{
// this culture isn't one of the ones, that can be set on this language.
logger.Warn(serializerType, "Culture {culture} is not one of the avalible cultures, so we cannot set this value", culture);
break;
continue;
}
}
else
Expand All @@ -461,7 +461,7 @@ protected Attempt<TObject, String> DeserializeProperties(TObject item, XElement
else
{
logger.Warn(serializerType, "Property {Alias} contains a value that has no culture but this property varies by culture so this value has no effect", alias);
break;
continue; // try with the next one.
}
}
}
Expand All @@ -472,8 +472,8 @@ protected Attempt<TObject, String> DeserializeProperties(TObject item, XElement
string.IsNullOrEmpty(culture) ? null : culture,
string.IsNullOrEmpty(segment) ? null : segment);

logger.Debug(serializerType, "Property {alias} value set", alias);
logger.Verbose(serializerType, "{Id} Property [{alias}] : {itemValue}", item.Id, alias, itemValue);
logger.Debug(serializerType, "Property {alias} {culture} : value set", alias, culture ?? "");
logger.Verbose(serializerType, "{Id} Property [{alias}] {culture} : {itemValue}", item.Id, alias,culture ?? "", itemValue);
}
catch (Exception ex)
{
Expand Down

0 comments on commit 7653143

Please sign in to comment.