mirror of
https://github.com/ish-app/ish.git
synced 2026-01-25 14:06:40 +00:00
Improve download script
- Add a timeout - Redownload files with the wrong size - Proxy Backblaze downloads through Cloudflare to save money on bandwidth
This commit is contained in:
parent
0ebe910b77
commit
dccc553879
11
deps/aports/download-repos.py
vendored
11
deps/aports/download-repos.py
vendored
@ -1,12 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
import socket
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import tarfile
|
||||
import pathlib
|
||||
import concurrent.futures
|
||||
|
||||
socket.setdefaulttimeout(5)
|
||||
|
||||
IX_NAME = 'P'
|
||||
IX_VERSION = 'V'
|
||||
IX_SIZE = 'S'
|
||||
|
||||
def read_index(index):
|
||||
index = index.read()
|
||||
@ -34,7 +38,8 @@ def download_repo(root_url, repo_name, index_name):
|
||||
pkg_file = f'{pkg[IX_NAME]}-{pkg[IX_VERSION]}.apk'
|
||||
url = f'{root_url}/{repo_name}/{urllib.parse.quote(pkg_file)}'
|
||||
path = repo/pkg_file
|
||||
if path.exists(): continue
|
||||
if path.exists() and path.stat().st_size == int(pkg[IX_SIZE]):
|
||||
continue
|
||||
downloads.append((url, path))
|
||||
download_many(downloads)
|
||||
|
||||
@ -58,5 +63,5 @@ def download_many(downloads):
|
||||
print(f'{done}/{len(futures)}', str(path))
|
||||
|
||||
if __name__ == '__main__':
|
||||
download_repo('https://f001.backblazeb2.com/file/alpine-archive', 'main/x86', 'APKINDEX-v3.12-2020-11-15.tar.gz')
|
||||
download_repo('https://f001.backblazeb2.com/file/alpine-archive', 'community/x86', 'APKINDEX-v3.12-2020-11-15.tar.gz')
|
||||
download_repo('https://b2-f001.ish.app/file/alpine-archive', 'main/x86', 'APKINDEX-v3.12-2020-11-15.tar.gz')
|
||||
download_repo('https://b2-f001.ish.app/file/alpine-archive', 'community/x86', 'APKINDEX-v3.12-2020-11-15.tar.gz')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user