[entropy.security] remove unlocked_sync(), locking happens externally nowadays

This commit is contained in:
Fabio Erculiani
2013-12-08 14:46:05 +01:00
parent 358c6cc80c
commit d0f11728c8
2 changed files with 7 additions and 37 deletions

View File

@@ -110,7 +110,7 @@ class Repository:
return br_rc
def _run_sync(self, _unlocked = False):
def _run_sync(self):
self.updated = False
for repo in self.repo_ids:
@@ -149,7 +149,7 @@ class Repository:
if self.updated:
self._entropy.clear_cache()
if self.fetch_security:
self._update_security_advisories(_unlocked = _unlocked)
self._update_security_advisories()
# do treeupdates
if isinstance(self._entropy.installed_repository(),
@@ -293,14 +293,10 @@ class Repository:
return True
return False
def _update_security_advisories(self, _unlocked = False):
# update Security Advisories
def _update_security_advisories(self):
try:
security_intf = self._entropy.Security()
if _unlocked:
security_intf.unlocked_sync(do_cache = False)
else:
security_intf.sync(do_cache = False)
security_intf.sync(do_cache = False)
except Exception as e:
entropy.tools.print_traceback(f = self._entropy.logger)
mytxt = "%s: %s" % (red(_("Advisories fetch error")), e,)
@@ -328,7 +324,7 @@ class Repository:
header = darkred(" @@ ")
)
rc = self._run_sync(_unlocked=True)
rc = self._run_sync()
if rc:
return rc

View File

@@ -31,7 +31,6 @@ from entropy.output import blue, bold, red, darkgreen, darkred, purple, brown
from entropy.cache import EntropyCacher
from entropy.core.settings.base import SystemSettings
from entropy.fetchers import UrlFetcher
from entropy.locks import EntropyResourcesLock
import entropy.tools
@@ -851,10 +850,9 @@ class System(object):
"""
return os.path.isdir(self.SECURITY_DIR)
def unlocked_sync(self, do_cache = True, force = False):
def sync(self, do_cache = True, force = False):
"""
This is equivalent to sync() but doesn't acquire the
Entropy Resources Lock.
This is the service method for remotely fetch advisories metadata.
@keyword do_cache: generates advisories cache
@type do_cache: bool
@@ -916,30 +914,6 @@ class System(object):
)
return rc_lock
def sync(self, do_cache = True, force = False):
"""
This is the service method for remotely fetch advisories metadata.
@keyword do_cache: generates advisories cache
@type do_cache: bool
@return: execution status (0 means all file)
@rtype: int
"""
lock = EntropyResourcesLock(output = self._entropy)
gave_up = lock.wait_resources()
if gave_up:
return 7
# acquired
try:
rc_lock = self.unlocked_sync(do_cache = do_cache,
force = force)
if rc_lock != 0:
return rc_lock
finally:
lock.unlock_resources()
return 0
def _setup_paths(self):
"""
Setup Entropy Security directory and file paths.