mirror of
https://github.com/wcbing/wcbing-apt-repo.git
synced 2025-12-29 02:28:30 +08:00
更改文件保存路径,便于将部分请求重定向到官网
This commit is contained in:
parent
8e33fb6f7d
commit
86d8ef4207
22
README.md
22
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` 目录暴露出去即可。
|
这个仓库使用了[扁平仓库格式(Flat Repository Format)](https://wiki.debian.org/DebianRepository/Format#Flat_Repository_Format)。建立好后使用 Web 服务器将 `deb` 目录暴露出去即可。
|
||||||
|
|
||||||
使用时可参考前面已有的配置,先将第3部提到的 GPG 公钥导入,再新建软件源配置文件。
|
使用时可参考前面已有的配置,先将第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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
@ -4,7 +4,10 @@ import sqlite3
|
|||||||
|
|
||||||
|
|
||||||
def download(url, file_type):
|
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 requests.get(url, stream=True) as res:
|
||||||
with open(file_path, "wb") as fw:
|
with open(file_path, "wb") as fw:
|
||||||
for chunk in res.iter_content(chunk_size=8192):
|
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),
|
(version, url, name),
|
||||||
)
|
)
|
||||||
# remove old version
|
# 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):
|
if os.path.exists(old_file_path):
|
||||||
os.remove(old_file_path)
|
os.remove(old_file_path)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user