Skip to content

Commit

Permalink
Merge branch 'hotfix/v3.5.4' into develop
Browse files Browse the repository at this point in the history
* hotfix/v3.5.4:
  Fix issue when "platformio lib uninstall" removes initial source code // Resolve #1023
  • Loading branch information
ivankravets committed Jun 21, 2018
2 parents 0875970 + 2725d8d commit b7ad642
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ PlatformIO 3.0
* Fixed issue with invalid LD script if path contains space
* Fixed preprocessor for Arduino sketch when function returns certain type
(`issue #1683 <https://github.com/platformio/platformio-core/issues/1683>`_)
* Fixed issue when `
platformio lib uninstall <http://docs.platformio.org/page/userguide/lib/cmd_uninstall.html>`__
removes initial source code
(`issue #1023 <https://github.com/platformio/platformio-core/issues/1023>`_)

3.5.3 (2018-06-01)
~~~~~~~~~~~~~~~~~~
Expand Down
12 changes: 9 additions & 3 deletions platformio/managers/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import re
import shutil
from os.path import basename, getsize, isdir, isfile, islink, join
from os.path import abspath, basename, getsize, isdir, isfile, islink, join
from tempfile import mkdtemp

import click
Expand Down Expand Up @@ -367,6 +367,12 @@ def get_package_dir(self, name, requirements=None, url=None):
return manifest.get("__pkg_dir") if manifest and isdir(
manifest.get("__pkg_dir")) else None

def get_package_by_dir(self, pkg_dir):
for manifest in self.get_installed():
if manifest['__pkg_dir'] == util.path_to_unicode(abspath(pkg_dir)):
return manifest
return None

def find_pkg_root(self, src_dir):
if self.manifest_exists(src_dir):
return src_dir
Expand Down Expand Up @@ -715,7 +721,7 @@ def install(self,
return pkg_dir

def uninstall(self, package, requirements=None, after_update=False):
if isdir(package):
if isdir(package) and self.get_package_by_dir(package):
pkg_dir = package
else:
name, requirements, url = self.parse_pkg_uri(package, requirements)
Expand Down Expand Up @@ -755,7 +761,7 @@ def uninstall(self, package, requirements=None, after_update=False):
return True

def update(self, package, requirements=None, only_check=False):
if isdir(package):
if isdir(package) and self.get_package_by_dir(package):
pkg_dir = package
else:
pkg_dir = self.get_package_dir(*self.parse_pkg_uri(package))
Expand Down

0 comments on commit b7ad642

Please sign in to comment.