Fix appmgr metadata fetching logic
This commit is contained in:
parent
d5a5962ee2
commit
f98edaff58
@ -54,13 +54,15 @@ class AppMgr:
|
|||||||
|
|
||||||
def fetch_online_packages(self):
|
def fetch_online_packages(self):
|
||||||
# Fetches and verifies online packages. Can raise InvalidSignature
|
# Fetches and verifies online packages. Can raise InvalidSignature
|
||||||
self.online_packages = {}
|
online_packages = {}
|
||||||
packages = self.get_repo_resource('packages').content
|
packages = self.get_repo_resource('packages').content
|
||||||
packages_sig = self.get_repo_resource('packages.sig').content
|
packages_sig = self.get_repo_resource('packages.sig').content
|
||||||
with open(PUB_FILE, 'rb') as f:
|
with open(PUB_FILE, 'rb') as f:
|
||||||
pub_key = load_pem_public_key(f.read(), default_backend())
|
pub_key = load_pem_public_key(f.read(), default_backend())
|
||||||
pub_key.verify(packages_sig, packages, ec.ECDSA(hashes.SHA512()))
|
pub_key.verify(packages_sig, packages, ec.ECDSA(hashes.SHA512()))
|
||||||
self.online_packages = json.loads(packages)
|
online_packages = json.loads(packages)
|
||||||
|
# Minimze the time when self.online_packages is out of sync
|
||||||
|
self.online_packages = online_packages
|
||||||
|
|
||||||
def enqueue_action(self, action, app):
|
def enqueue_action(self, action, app):
|
||||||
# Remove actions older than 1 day
|
# Remove actions older than 1 day
|
||||||
@ -110,7 +112,7 @@ class AppMgr:
|
|||||||
for dep in deps:
|
for dep in deps:
|
||||||
item.data.stage = 1
|
item.data.stage = 1
|
||||||
# Purge old data before unpacking to clean previous failed installation
|
# Purge old data before unpacking to clean previous failed installation
|
||||||
self.purge_package()
|
self.purge_package(dep)
|
||||||
self.unpack_package(dep)
|
self.unpack_package(dep)
|
||||||
for deps in deps:
|
for deps in deps:
|
||||||
item.data.stage = 3 if dep == deps[-1] else 2
|
item.data.stage = 3 if dep == deps[-1] else 2
|
||||||
@ -147,7 +149,8 @@ class AppMgr:
|
|||||||
|
|
||||||
def purge_package(self, name):
|
def purge_package(self, name):
|
||||||
# Removes package and shared data from filesystem
|
# Removes package and shared data from filesystem
|
||||||
lxc_dir = os.path.join(LXC_ROOT, self.conf['packages'][name]['lxcpath'])
|
lxcpath = self.conf['packages'][name]['lxcpath'] if name in self.conf['packages'] else self.online_packages[name]['lxcpath']
|
||||||
|
lxc_dir = os.path.join(LXC_ROOT, lxcpath)
|
||||||
if os.path.exists(lxc_dir):
|
if os.path.exists(lxc_dir):
|
||||||
shutil.rmtree(lxc_dir)
|
shutil.rmtree(lxc_dir)
|
||||||
srv_dir = os.path.join('/srv/', name)
|
srv_dir = os.path.join('/srv/', name)
|
||||||
|
Loading…
Reference in New Issue
Block a user