commit 0091c319279dc28adb6e830d7a715a503dcaf62b
parent 43d7c9114d8b2441d7c625aedb37a4283a5a4385
Author: ccx <ccx@te2000.cz>
Date: Thu, 31 Oct 2024 13:40:08 +0000
Remove old FileInfo implementation.
Use the generated filelist.sha256 for looking up file hashes instead.
Diffstat:
1 file changed, 0 insertions(+), 23 deletions(-)
diff --git a/genpkg.py b/genpkg.py
@@ -71,28 +71,6 @@ class DownloadsInfo:
return value
-class FileInfo:
- def __init__(self, files_dir, cache_dir):
- assert isinstance(files_dir, Path)
- assert isinstance(cache_dir, Path)
- self._files_dir = files_dir
- self._sha256_cache = {}
- self._by_sha256 = Path(cache_dir) / "link" / "files-sha256"
-
- def __getitem__(self, key):
- if key in self._sha256_cache:
- return self._sha256_cache[key]
- fp = self._files_dir / key
- with fp.open('rb') as f:
- file_hash = hashlib.file_digest(f, "sha256").hexdigest()
- self._sha256_cache[key] = file_hash
- if not (self._by_sha256 / file_hash).exists():
- raise RuntimeError(
- f"file {key!r} does not seem to be linked as {file_hash} from {self._by_sha256}"
- )
- return file_hash
-
-
def parse_filelist(filelist_path):
assert isinstance(filelist_path, Path)
with filelist_path.open('rt') as f:
@@ -127,7 +105,6 @@ class Main:
self.env.globals["pkg_install_name"] = self.pkg_install_name
self.env.globals["pkg_install_dir"] = self.pkg_install_dir
self.env.globals["submodule"] = SubmoduleInfo(cache_dir=cache_dir)
- # self.env.globals["files"] = FileInfo(files_dir=Path('files'), cache_dir=cache_dir)
self.env.globals["files"] = parse_filelist(index_dir / 'filelist.sha256')
self.env.globals["downloads"] = DownloadsInfo(index_dir / 'downloadlist.sha256')
self.package_hashes = {}