aptly_deb_usage: delete orphan files when deploy repos

Database cleanup removes information about unreferenced packages and
deletes files in the package pool that aren’t used by packages anymore.

Each time we deploy a repo, delete orphan files to keep the database
clean.

Story: 2008846
Task: 43867

Signed-off-by: ZhangXiao <xiao.zhang@windriver.com>
Change-Id: Id4365b6000484969f6b7a74b4e799271eb104dbc
This commit is contained in:
ZhangXiao 2021-11-16 16:59:58 +08:00
parent 262274093f
commit b86c4338ea

View File

@ -298,7 +298,7 @@ class Deb_aptly():
if self.aptly.tasks.show(task.id).state != 'SUCCEEDED':
self.logger.warning('Drop mirror failed %s : %s', name, self.aptly.tasks.show(task.id).state)
# Clean orphans
# Delete orphan files
task = self.aptly.db.cleanup()
self.aptly.tasks.wait_for_task_by_id(task.id)
@ -468,7 +468,11 @@ class Deb_aptly():
return None
if self.__create_snapshot(name, True):
return self.__publish_snap(name)
ret = self.__publish_snap(name)
# Delete orphan files
task = self.aptly.db.cleanup()
self.aptly.tasks.wait_for_task_by_id(task.id)
return ret
return None
# remove a local repository
@ -507,6 +511,10 @@ class Deb_aptly():
if self.aptly.tasks.show(task.id).state != 'SUCCEEDED':
self.logger.warning('Drop repo failed %s : %s', name, self.aptly.tasks.show(task.id).state)
# Delete orphan files
task = self.aptly.db.cleanup()
self.aptly.tasks.wait_for_task_by_id(task.id)
return None
# clean all metadata including remote, repository, public, distribution, task and content
@ -554,6 +562,6 @@ class Deb_aptly():
self.aptly.files.delete(file)
# clean tasks
self.aptly.tasks.clear()
# Clean orphans
# Delete orphan files
task = self.aptly.db.cleanup()
self.aptly.tasks.wait_for_task_by_id(task.id)