Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-594) Upgrading Extensions should not fail
  • Loading branch information
ferventcoder committed Jan 30, 2016
2 parents 9f34984 + a1474ea commit 4d37117
Showing 1 changed file with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace chocolatey.infrastructure.app.services
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using commandline;
using configuration;
Expand Down Expand Up @@ -730,9 +731,42 @@ private void handle_extension_packages(ChocolateyConfiguration config, PackageRe
var extensionsFolderName = packageResult.Name.to_lower().Replace(".extensions", string.Empty).Replace(".extension", string.Empty);
var pkgExtensions = _fileSystem.combine_paths(ApplicationParameters.ExtensionsLocation, extensionsFolderName);

if (_fileSystem.directory_exists(pkgExtensions))
{
// remove old dll files files
foreach (var oldDllFile in _fileSystem.get_files(pkgExtensions, "*.dll.old", SearchOption.AllDirectories).or_empty_list_if_null())
{
FaultTolerance.try_catch_with_logging_exception(
() => _fileSystem.delete_file(oldDllFile),
"Attempted to remove '{0}' but had an error".format_with(oldDllFile),
throwError: false,
logWarningInsteadOfError: true);
}

// rename possibly locked dll files
foreach (var dllFile in _fileSystem.get_files(pkgExtensions, "*.dll", SearchOption.AllDirectories).or_empty_list_if_null())
{
FaultTolerance.try_catch_with_logging_exception(
() => _fileSystem.move_file(dllFile, dllFile + ".old"),
"Attempted to rename '{0}' but had an error".format_with(dllFile));
}
}

FaultTolerance.try_catch_with_logging_exception(
() => _fileSystem.delete_directory_if_exists(pkgExtensions, recursive: true),
"Attempted to remove '{0}' but had an error".format_with(pkgExtensions));
() =>
{
foreach (var file in _fileSystem.get_files(pkgExtensions, "*.*", SearchOption.AllDirectories).or_empty_list_if_null().Where(f=> !f.EndsWith(".dll.old")))
{
FaultTolerance.try_catch_with_logging_exception(
() => _fileSystem.delete_file(file),
"Attempted to remove '{0}' but had an error".format_with(file),
throwError: false,
logWarningInsteadOfError: true);
}
},
"Attempted to remove '{0}' but had an error".format_with(pkgExtensions),
throwError: false,
logWarningInsteadOfError: true);

if (!config.CommandName.is_equal_to(CommandNameType.uninstall.to_string()))
{
Expand Down

0 comments on commit 4d37117

Please sign in to comment.