Skip to content

Commit

Permalink
CDIFFs clean up / changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Clark authored and micahsnyder committed Mar 12, 2022
1 parent ac6010f commit 7ec14a4
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions cvdupdate/cvdupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,33 @@ def clean_dbs(self):
"""
dbs = self.state['dbs'].keys()
for db in dbs:
cvddb = str(self.db_dir / db)
os.remove(cvddb)
self.logger.info(f"Deleted: {db}")
cvddb = self.db_dir / db
if cvddb.exists():
try:
self.logger.info(f"Deleting: {db}")
os.remove(str(cvddb))
except Exception as exc:
self.logger.debug(f"Tried to remove {db}")
raise exc

# Remove / clear all CDIFFs
cdiff_files = self.db_dir.glob('*.cdiff')
for cdiff in cdiff_files:
try:
self.logger.info(f"Deleting CDIFF: {cdiff.name}")
os.remove(str(cdiff))
except Exception as exc:
self.logger.debug(f"Tried to remove cdiffs.")

# Config cleanup
for db in dbs:
self.state['dbs'][db]['CDIFFs'] = []
self.state['dbs'][db]['last modified'] = 0
self.state['dbs'][db]['last checked'] = 0
self.state['dbs'][db]['local version'] = 0

# Save config
self._save_config()

def clean_logs(self):
"""
Expand Down

0 comments on commit 7ec14a4

Please sign in to comment.