Skip to content

Commit

Permalink
Do not uninstall an already installed module when trying to install
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastProject committed Mar 26, 2017
1 parent 6107a55 commit e545c76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- If module installation fails, the module directory is removed, so a subsequent installation doesn't instantly fail
- Modules are now correctly unloaded when they raise a critical error
- Installing a module that's already installed no longer uninstalls it (regression introduced in 0.5)

## [0.5] - 2017-03-22
### API changes
Expand Down
11 changes: 11 additions & 0 deletions pext/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ def install_module(self, url: str, verbose=False, interactive=True) -> bool:
dir_name = ModuleManager.add_prefix(module_name).replace('.', '_')
module_name = ModuleManager.remove_prefix(module_name)

if os.path.exists(os.path.join(self.module_dir, dir_name)):
if verbose:
self._log_error('{} is already installed'.format(module_name))

return False

if verbose:
self._log('Installing {} from {}'.format(module_name, url))

Expand Down Expand Up @@ -723,6 +729,11 @@ def install_module(self, url: str, verbose=False, interactive=True) -> bool:
except FileNotFoundError:
pass

try:
rmtree(os.path.join(self.module_dependencies_dir, dir_name))
except FileNotFoundError:
pass

return False

if verbose:
Expand Down

0 comments on commit e545c76

Please sign in to comment.