From 671083726df91a9edd8406bb036abe6aae7758a1 Mon Sep 17 00:00:00 2001 From: none Date: Sat, 24 Feb 2024 20:15:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B5=20?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=BE=D0=B5?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B0=D0=B4=D1=80=D0=B5=D1=81=D0=B0=20=D1=81=D0=B0=D0=B9=D1=82?= =?UTF-8?q?=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interface.py | 2 +- network.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/interface.py b/interface.py index bedeb2a..2b1ce79 100644 --- a/interface.py +++ b/interface.py @@ -7,5 +7,5 @@ from os import walk sites = next(walk('cached/'), (None, None, []))[1] 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})" diff --git a/network.py b/network.py index 38b8985..60795dd 100644 --- a/network.py +++ b/network.py @@ -8,7 +8,8 @@ from random import randint from shutil import unpack_archive # Убираем ненужное (../some => some) from re import compile, sub -# Timeout для команды +# Работа с БД +from db import read from verify import * from domain_check import * @@ -123,6 +124,21 @@ def client(port, op = "ping"): return data elif op[:4] == "get_": 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") print('SIZE: ', g_site.headers['Content-Length']) # Размер