Updated for check db

This commit is contained in:
Dimitris Zlatanidis 2023-05-08 13:54:28 +03:00
parent c07098648d
commit 06eedf1b80

View file

@ -69,18 +69,26 @@ class Check(Configs):
def is_empty_database(self) -> None:
""" Checking for empty table and database file. """
count: int = 0
sbo_table: dict = {
self.repos.sbo_repo_name: SBoTable,
self.repos.ponce_repo_name: PonceTable
}
if self.repository != '*':
if self.repository == '*':
for repository in list(self.repos.repositories.keys()):
if self.utils.is_binary_repo(repository):
count: int = self.session.query(BinariesTable.id).where(
BinariesTable.repo == repository).count()
else:
count: int = self.session.query(sbo_table[repository].id).count()
else:
if self.is_binary:
count: int = self.session.query(BinariesTable.id).where(BinariesTable.repo == self.repository).count()
else:
count: int = self.session.query(sbo_table[self.repository].id).count()
if count == 0:
self.errors.raise_error_message("You need to update the package lists first, run:\n\n"
" $ slpkg update",
exit_status=1)
if count == 0:
self.errors.raise_error_message("You need to update the package lists first, run:\n\n"
" $ slpkg update",
exit_status=1)