コード例 #1
0
        public void save_package_information(ChocolateyPackageInformation packageInformation)
        {
            _fileSystem.create_directory_if_not_exists(ApplicationParameters.ChocolateyPackageInfoStoreLocation);
            _fileSystem.ensure_file_attribute_set(ApplicationParameters.ChocolateyPackageInfoStoreLocation, FileAttributes.Hidden);

            if (packageInformation.Package == null)
            {
                this.Log().Debug("No package information to save as package is null.");
                return;
            }

            var pkgStorePath = _fileSystem.combine_paths(ApplicationParameters.ChocolateyPackageInfoStoreLocation, "{0}.{1}".format_with(packageInformation.Package.Id, packageInformation.Package.Version.to_string()));

            _fileSystem.create_directory_if_not_exists(pkgStorePath);

            if (packageInformation.RegistrySnapshot != null)
            {
                _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 (!string.IsNullOrWhiteSpace(packageInformation.Arguments))
            {
                var argsFile = _fileSystem.combine_paths(pkgStorePath, ARGS_FILE);
                if (_fileSystem.file_exists(argsFile))
                {
                    _fileSystem.delete_file(argsFile);
                }
                _fileSystem.write_file(argsFile, packageInformation.Arguments);
            }

            if (packageInformation.HasSilentUninstall)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, SILENT_UNINSTALLER_FILE), string.Empty, Encoding.ASCII);
            }
            if (packageInformation.IsSideBySide)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, SIDE_BY_SIDE_FILE), string.Empty, Encoding.ASCII);
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, SIDE_BY_SIDE_FILE));
            }

            if (packageInformation.IsPinned)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, PIN_FILE), string.Empty, Encoding.ASCII);
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, PIN_FILE));
            }
        }
コード例 #2
0
        public void save_package_information(ChocolateyPackageInformation packageInformation)
        {
            _fileSystem.create_directory_if_not_exists(ApplicationParameters.ChocolateyPackageInfoStoreLocation);
            _fileSystem.ensure_file_attribute_set(ApplicationParameters.ChocolateyPackageInfoStoreLocation, FileAttributes.Hidden);

            var pkgStorePath = _fileSystem.combine_paths(ApplicationParameters.ChocolateyPackageInfoStoreLocation, "{0}.{1}".format_with(packageInformation.Package.Id, packageInformation.Package.Version.to_string()));

            _fileSystem.create_directory_if_not_exists(pkgStorePath);

            if (packageInformation.RegistrySnapshot != null)
            {
                _registryService.save_to_file(packageInformation.RegistrySnapshot, _fileSystem.combine_paths(pkgStorePath, REGISTRY_SNAPSHOT_FILE));
            }

            if (packageInformation.HasSilentUninstall)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, SILENT_UNINSTALLER_FILE), string.Empty, Encoding.ASCII);
            }
            if (packageInformation.IsSideBySide)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, SIDE_BY_SIDE_FILE), string.Empty, Encoding.ASCII);
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, SIDE_BY_SIDE_FILE));
            }

            if (packageInformation.IsPinned)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, PIN_FILE), string.Empty, Encoding.ASCII);
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, PIN_FILE));
            }
        }
コード例 #3
0
        public void save_package_information(ChocolateyPackageInformation packageInformation)
        {
            _fileSystem.create_directory_if_not_exists(ApplicationParameters.ChocolateyPackageInfoStoreLocation);
            _fileSystem.ensure_file_attribute_set(ApplicationParameters.ChocolateyPackageInfoStoreLocation, FileAttributes.Hidden);

            if (packageInformation.Package == null)
            {
                this.Log().Debug("No package information to save as package is null.");
                return;
            }

            var pkgStorePath = _fileSystem.combine_paths(ApplicationParameters.ChocolateyPackageInfoStoreLocation, "{0}.{1}".format_with(packageInformation.Package.Id, packageInformation.Package.Version.to_string()));

            _fileSystem.create_directory_if_not_exists(pkgStorePath);

            if (packageInformation.RegistrySnapshot != null)
            {
                _registryService.save_to_file(packageInformation.RegistrySnapshot, _fileSystem.combine_paths(pkgStorePath, REGISTRY_SNAPSHOT_FILE));
            }

            if (packageInformation.FilesSnapshot != null)
            {
                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))
            {
                var argsFile = _fileSystem.combine_paths(pkgStorePath, ARGS_FILE);
                if (_fileSystem.file_exists(argsFile))
                {
                    _fileSystem.delete_file(argsFile);
                }
                _fileSystem.write_file(argsFile, packageInformation.Arguments);
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, ARGS_FILE));
            }

            if (!string.IsNullOrWhiteSpace(packageInformation.ExtraInformation))
            {
                var extraFile = _fileSystem.combine_paths(pkgStorePath, EXTRA_FILE);
                if (_fileSystem.file_exists(extraFile))
                {
                    _fileSystem.delete_file(extraFile);
                }
                _fileSystem.write_file(extraFile, packageInformation.ExtraInformation);
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, EXTRA_FILE));
            }

            if (packageInformation.VersionOverride != null)
            {
                var versionOverrideFile = _fileSystem.combine_paths(pkgStorePath, VERSION_OVERRIDE_FILE);
                if (_fileSystem.file_exists(versionOverrideFile))
                {
                    _fileSystem.delete_file(versionOverrideFile);
                }
                _fileSystem.write_file(versionOverrideFile, packageInformation.VersionOverride.to_string());
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, VERSION_OVERRIDE_FILE));
            }

            if (packageInformation.HasSilentUninstall)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, SILENT_UNINSTALLER_FILE), string.Empty, Encoding.ASCII);
            }
            if (packageInformation.IsSideBySide)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, SIDE_BY_SIDE_FILE), string.Empty, Encoding.ASCII);
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, SIDE_BY_SIDE_FILE));
            }

            if (packageInformation.IsPinned)
            {
                _fileSystem.write_file(_fileSystem.combine_paths(pkgStorePath, PIN_FILE), string.Empty, Encoding.ASCII);
            }
            else
            {
                _fileSystem.delete_file(_fileSystem.combine_paths(pkgStorePath, PIN_FILE));
            }
        }