Skip to content

Commit

Permalink
Merge 2979b35 into 44d5034
Browse files Browse the repository at this point in the history
  • Loading branch information
backstroke-bot committed Feb 9, 2018
2 parents 44d5034 + 2979b35 commit ebcfb38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
16 changes: 7 additions & 9 deletions package_control/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@


def clear_cache():
global _channel_repository_cache
_channel_repository_cache = {}
_channel_repository_cache.clear()


def get_cache(key, default=None):
Expand Down Expand Up @@ -50,7 +49,7 @@ def merge_cache_over_settings(destination, setting, key_prefix):
"""

existing = destination.settings.get(setting, {})
value = get_cache(key_prefix + '.' + setting, {})
value = get_cache(key_prefix + '.' + setting)
if value:
existing.update(value)
destination.settings[setting] = existing
Expand All @@ -75,14 +74,13 @@ def merge_cache_under_settings(destination, setting, key_prefix, list_=False):
If a list should be used instead of a dict
"""

default = {} if not list_ else []
existing = destination.settings.get(setting)
value = get_cache(key_prefix + '.' + setting, default)
value = get_cache(key_prefix + '.' + setting)
if value:
existing = destination.settings.get(setting)
if existing:
if list_:
# Prevent duplicate values
base = dict(zip(value, [None]*len(value)))
base = dict(zip(value, [None] * len(value)))
for val in existing:
if val in base:
continue
Expand Down Expand Up @@ -162,12 +160,12 @@ def set_cache_under_settings(destination, setting, key_prefix, value, ttl, list_
The cache ttl to use
"""

default = {} if not list_ else []
existing = destination.settings.get(setting, default)
if value:
if list_:
existing = destination.settings.get(setting, [])
value.extend(existing)
else:
existing = destination.settings.get(setting, {})
value.update(existing)
set_cache(key_prefix + '.' + setting, value, ttl)
destination.settings[setting] = value
8 changes: 3 additions & 5 deletions package_control/clear_directory.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os
import stat
import shutil
from fnmatch import fnmatch

from .console_write import console_write
from .unicode import unicode_from_os

Expand All @@ -18,7 +16,7 @@ def clean_old_files(directory):

for root, dirs, files in os.walk(directory, topdown=False):
for f in files:
if fnmatch(f, '*.package-control-old'):
if f.endswith('.package-control-old'):
path = os.path.join(root, f)
try:
os.remove(path)
Expand Down Expand Up @@ -70,7 +68,7 @@ def clear_directory(directory, ignore_paths=None):
except OSError:
# try to rename file to reduce chance that
# file is in use on next start
if path[-20:] != '.package-control-old':
if not path.endswith('.package-control-old'):
os.rename(path, path + '.package-control-old')
raise
except (OSError, IOError):
Expand Down Expand Up @@ -107,7 +105,7 @@ def _on_error(function, path, excinfo):
# python file that imports the .dll may never get deleted, meaning that
# the package can never be cleanly removed.
try:
if not os.path.isdir(path) and path[-20:] != '.package-control-old':
if not os.path.isdir(path) and not path.endswith('.package-control-old'):
os.rename(path, path + '.package-control-old')
except (OSError):
pass
Expand Down
7 changes: 3 additions & 4 deletions package_control/package_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,16 @@ def show_still_locked(package_name):
continue

metadata = self.manager.get_metadata(package)
if metadata:
if not self.is_compatible(metadata):
invalid_packages.append(package)
if metadata and not self.is_compatible(metadata):
invalid_packages.append(package)

# print( "package_cleanup.py, found_dependencies: %d\n" % len( found_dependencies ) + str( found_dependencies ) )

# Make sure installed dependencies are not improperly installed
for dependency in found_dependencies:
metadata = self.manager.get_metadata(dependency, is_dependency=True)
if metadata and not self.is_compatible(metadata):
invalid_dependencies.append(package)
invalid_dependencies.append(dependency)

if invalid_packages or invalid_dependencies:
def show_sync_error():
Expand Down

0 comments on commit ebcfb38

Please sign in to comment.