diff --git a/README.md b/README.md index c223623..4e8fce5 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,25 @@ crontab 样例:0 11,15,19 * * * cd [THIS_DIR] && ./update_gen.sh > ./deb/statu 这个仓库使用了[扁平仓库格式(Flat Repository Format)](https://wiki.debian.org/DebianRepository/Format#Flat_Repository_Format)。建立好后使用 Web 服务器将 `deb` 目录暴露出去即可。 使用时可参考前面已有的配置,先将第3部提到的 GPG 公钥导入,再新建软件源配置文件。 + +实际使用中官网提供的下载链接一般是 CDN 链接,为提升下载速度,减轻自建源压力,建议将这些请求重定向到官网上。而国内下载 Github 上的文件时比较慢,仍然从自建源下载。 + +nginx 配置参考: +```nginx +server { + server_name packages.wcbing.top; + autoindex on; + autoindex_exact_size off; + autoindex_localtime on; + charset 'utf-8'; + location ~ ^/deb/https:/github.com { + root /packages; + } + location ~ ^/deb/https:/(.+)$ { + return 302 https://$1; + } + location / { + root /packages; + } +} +``` \ No newline at end of file diff --git a/get/module/check.py b/get/module/check.py index 64c48ad..295cc4c 100644 --- a/get/module/check.py +++ b/get/module/check.py @@ -4,7 +4,10 @@ import sqlite3 def download(url, file_type): - file_path = os.path.join(file_type, str(url.split("/")[-1])) + file_dir = os.path.join(file_type, "/".join(url.split("/")[:-1])) + if not os.path.exists(file_dir): + os.makedirs(file_dir) + file_path = os.path.join(file_type, url) with requests.get(url, stream=True) as res: with open(file_path, "wb") as fw: for chunk in res.iter_content(chunk_size=8192): @@ -32,7 +35,7 @@ def check_download(name, version, url, arch, file_type): (version, url, name), ) # remove old version - old_file_path = os.path.join(file_type, str(db_url.split("/")[-1])) + old_file_path = os.path.join(file_type, db_url) if os.path.exists(old_file_path): os.remove(old_file_path) else: