Skip to content

Commit

Permalink
(GH-1328) Serialize/deserialize package files warnings
Browse files Browse the repository at this point in the history
Instead of defaulting to errorrs, silently have those warnings come up.
When installing the package, if the save of the files snapshot fails,
log a warning but allow the install to be successful.

This corrects seeing these kinds of errors:

~~~
Error deserializing response of type
chocolatey.infrastructure.app.domain.PackageFiles:
 '.', hexadecimal value 0x00, is an invalid character. Line 1, position
1.
~~~
  • Loading branch information
ferventcoder committed Jun 8, 2017
1 parent 17560b5 commit e2c4e9b
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ public ChocolateyPackageInformation get_package_information(IPackage package)
packageInformation.RegistrySnapshot = _registryService.read_from_file(_fileSystem.combine_paths(pkgStorePath, REGISTRY_SNAPSHOT_FILE));
},
"Unable to read registry snapshot file for {0} (located at {1})".format_with(package.Id, _fileSystem.combine_paths(pkgStorePath, REGISTRY_SNAPSHOT_FILE)),
throwError: false,
logWarningInsteadOfError: true
throwError: false,
logWarningInsteadOfError: true,
isSilent: true
);

FaultTolerance.try_catch_with_logging_exception(
Expand All @@ -77,7 +78,8 @@ public ChocolateyPackageInformation get_package_information(IPackage package)
},
"Unable to read files snapshot file",
throwError: false,
logWarningInsteadOfError: true
logWarningInsteadOfError: true,
isSilent:true
);

packageInformation.HasSilentUninstall = _fileSystem.file_exists(_fileSystem.combine_paths(pkgStorePath, SILENT_UNINSTALLER_FILE));
Expand Down Expand Up @@ -127,7 +129,15 @@ public void save_package_information(ChocolateyPackageInformation packageInforma

if (packageInformation.FilesSnapshot != null)
{
_filesService.save_to_file(packageInformation.FilesSnapshot, _fileSystem.combine_paths(pkgStorePath, FILES_SNAPSHOT_FILE));
FaultTolerance.try_catch_with_logging_exception(
() =>
{
_filesService.save_to_file(packageInformation.FilesSnapshot, _fileSystem.combine_paths(pkgStorePath, FILES_SNAPSHOT_FILE));
},
"Unable to save files snapshot",
throwError: false,
logWarningInsteadOfError: true
);
}

if (!string.IsNullOrWhiteSpace(packageInformation.Arguments))
Expand Down

0 comments on commit e2c4e9b

Please sign in to comment.