mirror of
https://github.com/Justuser3310/jetwork.git
synced 2025-02-08 01:37:38 +00:00
Проверка версии при загрузке и небольшое изменение адреса сайтов.
This commit is contained in:
parent
3dca4630aa
commit
671083726d
@ -7,5 +7,5 @@ from os import walk
|
|||||||
sites = next(walk('cached/'), (None, None, []))[1]
|
sites = next(walk('cached/'), (None, None, []))[1]
|
||||||
|
|
||||||
for i in sites:
|
for i in sites:
|
||||||
addr = f"http://127.0.0.1:8000/{i}/index.html"
|
addr = f"http://127.0.0.1:8000/{i}"
|
||||||
f"[{i}]({addr})"
|
f"[{i}]({addr})"
|
||||||
|
18
network.py
18
network.py
@ -8,7 +8,8 @@ from random import randint
|
|||||||
from shutil import unpack_archive
|
from shutil import unpack_archive
|
||||||
# Убираем ненужное (../some => some)
|
# Убираем ненужное (../some => some)
|
||||||
from re import compile, sub
|
from re import compile, sub
|
||||||
# Timeout для команды
|
# Работа с БД
|
||||||
|
from db import read
|
||||||
|
|
||||||
from verify import *
|
from verify import *
|
||||||
from domain_check import *
|
from domain_check import *
|
||||||
@ -123,6 +124,21 @@ def client(port, op = "ping"):
|
|||||||
return data
|
return data
|
||||||
elif op[:4] == "get_":
|
elif op[:4] == "get_":
|
||||||
site = op[4:]
|
site = op[4:]
|
||||||
|
|
||||||
|
# Проверяем версию если сайт кеширован
|
||||||
|
if os.path.exists(f"cached/{site}"):
|
||||||
|
# Версия запрашиваемого
|
||||||
|
dest_conf = get(f"http://{host}:{str(port)}/{site}/config.json")
|
||||||
|
conf_unform = dest_ver.content.decode('utf8')
|
||||||
|
conf = json.loads(conf_unform)
|
||||||
|
dest_ver = conf["ver"]
|
||||||
|
# Версия нашего сайта
|
||||||
|
our_conf = read(f"cached/{site}/config.json")
|
||||||
|
our_ver = our_conf["ver"]
|
||||||
|
# Если версия не новее - не скачиваем
|
||||||
|
if our_ver >= dest_ver:
|
||||||
|
return "old"
|
||||||
|
|
||||||
# Скачиваем файлы
|
# Скачиваем файлы
|
||||||
g_site = get(f"http://{host}:{str(port)}/{site}.zip")
|
g_site = get(f"http://{host}:{str(port)}/{site}.zip")
|
||||||
print('SIZE: ', g_site.headers['Content-Length']) # Размер
|
print('SIZE: ', g_site.headers['Content-Length']) # Размер
|
||||||
|
Loading…
Reference in New Issue
Block a user