forked from importers/git-importer
		
	optimize cached file locations and add option for cache directory
This commit is contained in:
		| @@ -12,7 +12,7 @@ from lib.tree_builder import TreeBuilder | ||||
|  | ||||
|  | ||||
| class GitExporter: | ||||
|     def __init__(self, api_url, project, package, repodir): | ||||
|     def __init__(self, api_url, project, package, repodir, cachedir): | ||||
|         self.obs = OBS() | ||||
|         self.project = project | ||||
|         self.package = package | ||||
| @@ -26,6 +26,7 @@ class GitExporter: | ||||
|         ).create() | ||||
|         self.state_file = os.path.join(self.git.path, ".git", "_flat_state.yaml") | ||||
|         self.gc_interval = 200 | ||||
|         self.cachedir = cachedir | ||||
|  | ||||
|     def download(self, revision): | ||||
|         obs_files = self.obs.files(revision.project, revision.package, revision.srcmd5) | ||||
| @@ -40,10 +41,7 @@ class GitExporter: | ||||
|  | ||||
|         # Download each file in OBS if it is not a binary (or large) | ||||
|         # file | ||||
|         for (name, size, file_md5) in obs_files: | ||||
|             # Validate the MD5 of the downloaded file | ||||
|             if md5(self.git.path / name) != file_md5: | ||||
|                 raise Exception(f"Download error in {name}") | ||||
|         for name in obs_files: | ||||
|             self.git.add(name) | ||||
|  | ||||
|     def set_gc_interval(self, gc): | ||||
| @@ -121,6 +119,7 @@ class GitExporter: | ||||
|                     file.name, | ||||
|                     flat.commit.expanded_srcmd5, | ||||
|                     self.git.path, | ||||
|                     self.cachedir, | ||||
|                     file_md5=md5, | ||||
|                 ) | ||||
|                 self.git.add(file) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user