1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-08-16 11:20:10 +02:00

Flush file before passing it to next function

When downloading a repo index, the downloaded index got written to a
file with `.write()` in a `with` clause. Before the file got actually
written to the disk, it got already passed into the next function,
resulting in a `VerificationException`:
```
JAR signature failed to verify: /tmp/tmppq2r51r0
jarsigner: java.util.zip.ZipException: zip file is empty
```

This behavior got introduced in
869cc114a3.

I've found this bug with help of Repomaker's tests: https://gitlab.com/fdroid/repomaker/merge_requests/215#note_148994053
This commit is contained in:
Nico Alt 2019-03-22 17:15:58 +01:00
parent edfd3cf530
commit 3798a884a6

View File

@ -717,6 +717,7 @@ def download_repo_index(url_str, etag=None, verify_fingerprint=True, timeout=600
with tempfile.NamedTemporaryFile() as fp:
fp.write(download)
fp.flush()
index, public_key, public_key_fingerprint = get_index_from_jar(fp.name, fingerprint)
index["repo"]["pubkey"] = hexlify(public_key).decode()
index["repo"]["fingerprint"] = public_key_fingerprint