mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 14:32:28 +03:00
Merge branch 'cache-srcname-sha256' into 'master'
update: cache the SHA-256 of the src tarball Closes #1290 See merge request fdroid/fdroidserver!1686
This commit is contained in:
commit
058f0b7f6a
2 changed files with 16 additions and 4 deletions
|
@ -595,7 +595,10 @@ def convert_version(version, app, repodir):
|
|||
ver["file"]["ipfsCIDv1"] = ipfsCIDv1
|
||||
|
||||
if "srcname" in version:
|
||||
ver["src"] = common.file_entry(os.path.join(repodir, version["srcname"]))
|
||||
ver["src"] = common.file_entry(
|
||||
os.path.join(repodir, version["srcname"]),
|
||||
version["srcnameSha256"],
|
||||
)
|
||||
|
||||
if "obbMainFile" in version:
|
||||
ver["obbMainFile"] = common.file_entry(
|
||||
|
@ -964,7 +967,7 @@ def make_v1(apps, packages, repodir, repodict, requestsdict, signer_fingerprints
|
|||
for k, v in sorted(package.items()):
|
||||
if not v:
|
||||
continue
|
||||
if k in ('icon', 'icons', 'icons_src', 'ipfsCIDv1', 'name'):
|
||||
if k in ('icon', 'icons', 'icons_src', 'ipfsCIDv1', 'name', 'srcnameSha256'):
|
||||
continue
|
||||
if k == 'antiFeatures':
|
||||
d[k] = sorted(v.keys())
|
||||
|
|
|
@ -370,6 +370,11 @@ def get_cache():
|
|||
v['antiFeatures'] = {k: {} for k in sorted(v['antiFeatures'])}
|
||||
if 'added' in v:
|
||||
v['added'] = datetime.fromtimestamp(v['added'], tz=timezone.utc)
|
||||
if v.get('srcname') and not v.get('srcnameSha256'):
|
||||
f = f'archive/{v["srcname"]}'
|
||||
if not os.path.exists(f):
|
||||
f = f'repo/{v["srcname"]}'
|
||||
v['srcnameSha256'] = common.sha256sum(f)
|
||||
|
||||
return apkcache
|
||||
|
||||
|
@ -1570,8 +1575,10 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
|
|||
repo_file['packageName'] = m.group(1)
|
||||
repo_file['versionCode'] = int(m.group(2))
|
||||
srcfilename = name + b'_src.tar.gz'
|
||||
if os.path.exists(os.path.join(repodir, srcfilename)):
|
||||
srcpath = os.path.join(repodir, srcfilename)
|
||||
if os.path.exists(srcpath):
|
||||
repo_file['srcname'] = srcfilename.decode()
|
||||
repo_file['srcnameSha256'] = common.sha256sum(srcpath.decode())
|
||||
repo_file['size'] = stat.st_size
|
||||
|
||||
apkcache[name_utf8] = repo_file
|
||||
|
@ -1989,8 +1996,10 @@ def process_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk=Fal
|
|||
|
||||
apk['apkName'] = apkfilename
|
||||
srcfilename = apkfilename[:-4] + "_src.tar.gz"
|
||||
if os.path.exists(os.path.join(repodir, srcfilename)):
|
||||
srcpath = os.path.join(repodir, srcfilename)
|
||||
if os.path.exists(srcpath):
|
||||
apk['srcname'] = srcfilename
|
||||
apk['srcnameSha256'] = common.sha256sum(srcpath)
|
||||
|
||||
# verify the jar signature is correct, allow deprecated
|
||||
# algorithms only if the APK is in the archive.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue