Change debug output for downloading files

This commit is contained in:
Stephan Kulow 2022-11-06 09:59:09 +01:00
parent 834cf61634
commit 9114c2fff8
2 changed files with 3 additions and 6 deletions

View File

@ -1,6 +1,5 @@
from __future__ import annotations from __future__ import annotations
import logging
from hashlib import md5 from hashlib import md5
from pathlib import Path from pathlib import Path
from typing import Optional from typing import Optional
@ -235,7 +234,6 @@ class DBRevision:
If it's None, the repository is empty. If it's None, the repository is empty.
""" """
to_download = [] to_download = []
to_delete = []
if current_rev: if current_rev:
old_files = { old_files = {
e["name"]: f"{e['md5']}-{e['size']}" for e in current_rev.files_list() e["name"]: f"{e['md5']}-{e['size']}" for e in current_rev.files_list()
@ -244,12 +242,9 @@ class DBRevision:
old_files = dict() old_files = dict()
for entry in self.files_list(): for entry in self.files_list():
if old_files.get(entry["name"]) != f"{entry['md5']}-{entry['size']}": if old_files.get(entry["name"]) != f"{entry['md5']}-{entry['size']}":
logging.debug(f"Download {entry['name']}")
to_download.append((Path(entry["name"]), entry["size"], entry["md5"])) to_download.append((Path(entry["name"]), entry["size"], entry["md5"]))
old_files.pop(entry["name"], None) old_files.pop(entry["name"], None)
for entry in old_files.keys(): to_delete = [Path(e) for e in old_files.keys()]
logging.debug(f"Delete {entry}")
to_delete.append(Path(entry))
return to_download, to_delete return to_download, to_delete
@staticmethod @staticmethod

View File

@ -168,6 +168,7 @@ class OBS:
cached_file = self._path_from_md5(name, cachedir, file_md5) cached_file = self._path_from_md5(name, cachedir, file_md5)
if not self.in_cache(name, cachedir, file_md5): if not self.in_cache(name, cachedir, file_md5):
with (dirpath / name).open("wb") as f: with (dirpath / name).open("wb") as f:
logging.debug(f"Download {project}/{package}/{name}")
f.write(self._download(project, package, name, revision).read()) f.write(self._download(project, package, name, revision).read())
# Validate the MD5 of the downloaded file # Validate the MD5 of the downloaded file
@ -178,6 +179,7 @@ class OBS:
os.rename(cached_file.with_suffix(".new"), cached_file) os.rename(cached_file.with_suffix(".new"), cached_file)
else: else:
shutil.copy(cached_file, dirpath / name) shutil.copy(cached_file, dirpath / name)
logging.debug(f"Use cached {project}/{package}/{name}")
def list(self, project, package, srcmd5, linkrev): def list(self, project, package, srcmd5, linkrev):
params = {"rev": srcmd5, "expand": "1"} params = {"rev": srcmd5, "expand": "1"}