forked from importers/git-importer
Add the file_md5 to the download function so it can cache and verify
This commit is contained in:
parent
a1ead29734
commit
05cf792b26
@ -216,8 +216,7 @@ class DBRevision:
|
|||||||
to_delete = []
|
to_delete = []
|
||||||
if current_rev:
|
if current_rev:
|
||||||
old_files = {
|
old_files = {
|
||||||
e["name"]: f"{entry['md5']}-{entry['size']}"
|
e["name"]: f"{e['md5']}-{e['size']}" for e in current_rev.files_list(db)
|
||||||
for e in current_rev.files_list(db)
|
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
old_files = dict()
|
old_files = dict()
|
||||||
|
@ -66,6 +66,7 @@ class GitExporter:
|
|||||||
name,
|
name,
|
||||||
revision.srcmd5,
|
revision.srcmd5,
|
||||||
self.git.path,
|
self.git.path,
|
||||||
|
file_md5=file_md5,
|
||||||
)
|
)
|
||||||
# Validate the MD5 of the downloaded file
|
# Validate the MD5 of the downloaded file
|
||||||
if md5(self.git.path / name) != file_md5:
|
if md5(self.git.path / name) != file_md5:
|
||||||
@ -137,7 +138,7 @@ class GitExporter:
|
|||||||
if not self.limit_download(file):
|
if not self.limit_download(file):
|
||||||
continue
|
continue
|
||||||
self.git.remove(file)
|
self.git.remove(file)
|
||||||
for file in to_download:
|
for file, md5 in to_download:
|
||||||
if not self.limit_download(file):
|
if not self.limit_download(file):
|
||||||
continue
|
continue
|
||||||
self.obs.download(
|
self.obs.download(
|
||||||
@ -146,6 +147,7 @@ class GitExporter:
|
|||||||
file,
|
file,
|
||||||
flat.commit.expanded_srcmd5,
|
flat.commit.expanded_srcmd5,
|
||||||
self.git.path,
|
self.git.path,
|
||||||
|
file_md5=md5,
|
||||||
)
|
)
|
||||||
self.git.add(file)
|
self.git.add(file)
|
||||||
|
|
||||||
|
@ -152,7 +152,13 @@ class OBS:
|
|||||||
return osc.core.http_GET(url)
|
return osc.core.http_GET(url)
|
||||||
|
|
||||||
def download(
|
def download(
|
||||||
self, project: str, package: str, name: str, revision: str, dirpath: str
|
self,
|
||||||
|
project: str,
|
||||||
|
package: str,
|
||||||
|
name: str,
|
||||||
|
revision: str,
|
||||||
|
dirpath: str,
|
||||||
|
file_md5: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
with (dirpath / name).open("wb") as f:
|
with (dirpath / name).open("wb") as f:
|
||||||
f.write(self._download(project, package, name, revision).read())
|
f.write(self._download(project, package, name, revision).read())
|
||||||
|
Loading…
Reference in New Issue
Block a user