/// <summary> /// Save a pending ReadMe if changes are detected. /// </summary> /// <param name="package">Package entity associated with the ReadMe.</param> /// <param name="edit">Package edit entity.</param> /// <returns>True if a ReadMe is pending, false otherwise.</returns> public async Task <bool> SavePendingReadMeMdIfChanged(Package package, EditPackageVersionRequest edit, Encoding encoding) { var activeReadMe = package.HasReadMe ? NormalizeNewLines(await GetReadMeMdAsync(package)) : null; var newReadMe = HasReadMeSource(edit?.ReadMe) ? NormalizeNewLines(await GetReadMeMdAsync(edit.ReadMe, encoding)) : null; var hasReadMe = !string.IsNullOrWhiteSpace(newReadMe); if (hasReadMe && !newReadMe.Equals(activeReadMe)) { await _packageFileService.SavePendingReadMeMdFileAsync(package, newReadMe); edit.ReadMeState = PackageEditReadMeState.Changed; } else if (!hasReadMe && !string.IsNullOrEmpty(activeReadMe)) { await _packageFileService.DeleteReadMeMdFileAsync(package, isPending : true); edit.ReadMeState = PackageEditReadMeState.Deleted; } else { edit.ReadMeState = PackageEditReadMeState.Unchanged; } return(hasReadMe); }