Download .spec and .changes file only for now
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from hashlib import md5
|
||||
|
||||
from lib.db import DB
|
||||
from lib.request import Request
|
||||
|
||||
|
||||
@@ -202,6 +203,24 @@ class DBRevision:
|
||||
self._files.sort(key=lambda x: x["name"])
|
||||
return self._files
|
||||
|
||||
def calc_delta(self, db: DB, current_rev=None):
|
||||
"""Calculate the list of files to download and to delete"""
|
||||
old_files = dict()
|
||||
to_download = []
|
||||
to_delete = []
|
||||
if current_rev:
|
||||
for entry in current_rev.files_list(db):
|
||||
old_files[entry["name"]] = f"{entry['md5']}-{entry['size']}"
|
||||
for entry in self.files_list(db):
|
||||
if old_files.get(entry["name"], "") != f"{entry['md5']}-{entry['size']}":
|
||||
print("Download", entry["name"])
|
||||
to_download.append(entry["name"])
|
||||
old_files.pop(entry["name"], None)
|
||||
for entry in old_files.keys():
|
||||
print("Delete", entry)
|
||||
to_delete.append(entry)
|
||||
return to_download, to_delete
|
||||
|
||||
@staticmethod
|
||||
def requests_to_fetch(db):
|
||||
with db.cursor() as cur:
|
||||
|
||||
Reference in New Issue
Block a user