Bugfixed to check if database is empty #145

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-10-28 20:27:00 +03:00
parent ddadb5ef37
commit 6569bdf721
2 changed files with 15 additions and 2 deletions

View file

@ -14,10 +14,11 @@ class Check:
''' Some checks before proceed. '''
log_packages: str = Configs.log_packages
sbo_repo_tag: str = Configs.sbo_repo_tag
db_path: str = Configs.db_path
database_name: str = Configs.database
def exists(self, slackbuilds: list):
''' Checking if the slackbuild exists in the repository. '''
self.database()
packages = []
for sbo in slackbuilds:
@ -59,6 +60,7 @@ class Check:
def database(self):
''' Checking for empty table '''
if not SBoQueries('').names():
db = f'{self.db_path}/{self.database_name}'
if not SBoQueries('').names() or not os.path.isfile(db):
raise SystemExit('\nYou need to update the package lists first.\n'
'Please run slpkg update.\n')

View file

@ -70,6 +70,8 @@ class Argparse:
upgrade = Upgrade()
packages = list(upgrade.packages())
self.check.database()
if not packages:
print('\nEverything is up-to-date.\n')
raise SystemExit()
@ -83,6 +85,7 @@ class Argparse:
if len(self.args) >= 2 and '--reinstall' not in self.flags:
packages = list(set(self.args[1:]))
self.check.database()
self.check.exists(packages)
self.check.unsupported(packages)
@ -95,6 +98,7 @@ class Argparse:
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
self.check.database()
self.check.exists(packages)
self.check.unsupported(packages)
@ -110,6 +114,7 @@ class Argparse:
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
self.check.database()
self.check.exists(packages)
download = Download(self.flags)
download.packages(packages)
@ -125,6 +130,7 @@ class Argparse:
packages = list(set(self.args[1:]))
packages = self.check.blacklist(packages)
self.check.database()
self.check.installed(packages)
remove = RemovePackages(packages, self.flags)
@ -137,6 +143,7 @@ class Argparse:
packages = list(set(self.args[1:]))
packages = self.check.blacklist(packages)
self.check.database()
self.check.exists(packages)
view = ViewPackage()
@ -149,6 +156,7 @@ class Argparse:
packages = list(set(self.args[1:]))
packages = self.check.blacklist(packages)
self.check.database()
search = SearchPackage()
search.package(packages)
raise SystemExit()
@ -159,6 +167,7 @@ class Argparse:
packages = list(set(self.args[1:]))
packages = self.check.blacklist(packages)
self.check.database()
find = FindInstalled()
find.find(packages)
raise SystemExit()
@ -169,6 +178,8 @@ class Argparse:
usage(1)
if len(self.args) == 1:
self.check.database()
logs = CleanLogsDependencies(self.flags)
logs.clean()
raise SystemExit()