diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs index 31a5a59721..d6cf21d4e0 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs @@ -27,15 +27,18 @@ internal class ChocolateyPackageInformationService : IChocolateyPackageInformati { private readonly IFileSystem _fileSystem; private readonly IRegistryService _registryService; + private readonly IFilesService _filesService; private const string REGISTRY_SNAPSHOT_FILE = ".registry"; + private const string FILES_SNAPSHOT_FILE = ".files"; private const string SILENT_UNINSTALLER_FILE = ".silentUninstaller"; private const string SIDE_BY_SIDE_FILE = ".sxs"; private const string PIN_FILE = ".pin"; - public ChocolateyPackageInformationService(IFileSystem fileSystem, IRegistryService registryService) + public ChocolateyPackageInformationService(IFileSystem fileSystem, IRegistryService registryService, IFilesService filesService) { _fileSystem = fileSystem; _registryService = registryService; + _filesService = filesService; } public ChocolateyPackageInformation get_package_information(IPackage package) @@ -63,6 +66,16 @@ public ChocolateyPackageInformation get_package_information(IPackage package) logWarningInsteadOfError: true ); + FaultTolerance.try_catch_with_logging_exception( + () => + { + packageInformation.FilesSnapshot = _filesService.read_from_file(_fileSystem.combine_paths(pkgStorePath, FILES_SNAPSHOT_FILE)); + }, + "Unable to read files snapshot file", + throwError: false, + logWarningInsteadOfError: true + ); + packageInformation.HasSilentUninstall = _fileSystem.file_exists(_fileSystem.combine_paths(pkgStorePath, SILENT_UNINSTALLER_FILE)); packageInformation.IsSideBySide = _fileSystem.file_exists(_fileSystem.combine_paths(pkgStorePath, SIDE_BY_SIDE_FILE)); packageInformation.IsPinned = _fileSystem.file_exists(_fileSystem.combine_paths(pkgStorePath, PIN_FILE)); @@ -89,6 +102,11 @@ public void save_package_information(ChocolateyPackageInformation packageInforma _registryService.save_to_file(packageInformation.RegistrySnapshot, _fileSystem.combine_paths(pkgStorePath, REGISTRY_SNAPSHOT_FILE)); } + if (packageInformation.FilesSnapshot != null) + { + _filesService.save_to_file(packageInformation.FilesSnapshot, _fileSystem.combine_paths(pkgStorePath, FILES_SNAPSHOT_FILE)); + } + if (packageInformation.HasSilentUninstall) { _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, SILENT_UNINSTALLER_FILE), string.Empty, Encoding.ASCII);