mirror of
https://github.com/taoky/shadowmire.git
synced 2025-07-08 09:12:43 +00:00
parent
a913965c22
commit
b5fca47101
@ -621,7 +621,7 @@ class SyncBase:
|
|||||||
def write_meta_to_simple(self, package_simple_path: Path, meta: dict) -> None:
|
def write_meta_to_simple(self, package_simple_path: Path, meta: dict) -> None:
|
||||||
simple_html_contents = PyPI.generate_html_simple_page(meta)
|
simple_html_contents = PyPI.generate_html_simple_page(meta)
|
||||||
simple_json_contents = PyPI.generate_json_simple_page(meta)
|
simple_json_contents = PyPI.generate_json_simple_page(meta)
|
||||||
for html_filename in ("index.html", "index.v1_html"):
|
for html_filename in ("index.v1_html",):
|
||||||
html_path = package_simple_path / html_filename
|
html_path = package_simple_path / html_filename
|
||||||
with overwrite(html_path) as f:
|
with overwrite(html_path) as f:
|
||||||
f.write(simple_html_contents)
|
f.write(simple_html_contents)
|
||||||
@ -629,6 +629,11 @@ class SyncBase:
|
|||||||
json_path = package_simple_path / json_filename
|
json_path = package_simple_path / json_filename
|
||||||
with overwrite(json_path) as f:
|
with overwrite(json_path) as f:
|
||||||
f.write(simple_json_contents)
|
f.write(simple_json_contents)
|
||||||
|
index_html_path = package_simple_path / "index.html"
|
||||||
|
if not index_html_path.is_symlink():
|
||||||
|
if index_html_path.exists():
|
||||||
|
index_html_path.unlink()
|
||||||
|
index_html_path.symlink_to("index.v1_html")
|
||||||
|
|
||||||
def finalize(self) -> None:
|
def finalize(self) -> None:
|
||||||
local_names = self.local_db.keys()
|
local_names = self.local_db.keys()
|
||||||
@ -1051,7 +1056,9 @@ def genlocal(ctx: click.Context) -> None:
|
|||||||
serial = get_local_serial(package_metapath)
|
serial = get_local_serial(package_metapath)
|
||||||
if serial:
|
if serial:
|
||||||
local[package_name] = serial
|
local[package_name] = serial
|
||||||
logger.info("%d out of %d packages have valid serial number", len(local), len(dir_items))
|
logger.info(
|
||||||
|
"%d out of %d packages have valid serial number", len(local), len(dir_items)
|
||||||
|
)
|
||||||
local_db.nuke(commit=False)
|
local_db.nuke(commit=False)
|
||||||
local_db.batch_set(local)
|
local_db.batch_set(local)
|
||||||
local_db.dump_json()
|
local_db.dump_json()
|
||||||
@ -1093,7 +1100,11 @@ def verify(
|
|||||||
simple_dirs = {i.name for i in (basedir / "simple").iterdir() if i.is_dir()}
|
simple_dirs = {i.name for i in (basedir / "simple").iterdir() if i.is_dir()}
|
||||||
json_files = {i.name for i in (basedir / "json").iterdir() if i.is_file()}
|
json_files = {i.name for i in (basedir / "json").iterdir() if i.is_file()}
|
||||||
not_in_local = (simple_dirs | json_files) - local_names
|
not_in_local = (simple_dirs | json_files) - local_names
|
||||||
logger.info("%d out of %d local packages NOT in local db", len(not_in_local), len(local_names))
|
logger.info(
|
||||||
|
"%d out of %d local packages NOT in local db",
|
||||||
|
len(not_in_local),
|
||||||
|
len(local_names),
|
||||||
|
)
|
||||||
for package_name in not_in_local:
|
for package_name in not_in_local:
|
||||||
logger.info("package %s not in local db", package_name)
|
logger.info("package %s not in local db", package_name)
|
||||||
if remove_not_in_local:
|
if remove_not_in_local:
|
||||||
@ -1127,7 +1138,9 @@ def verify(
|
|||||||
)
|
)
|
||||||
syncer.finalize()
|
syncer.finalize()
|
||||||
|
|
||||||
logger.info("====== Step 4. Remove any unreferenced files in `packages` folder ======")
|
logger.info(
|
||||||
|
"====== Step 4. Remove any unreferenced files in `packages` folder ======"
|
||||||
|
)
|
||||||
ref_set = set()
|
ref_set = set()
|
||||||
for sname in tqdm(simple_dirs, desc="Iterating simple/ directory"):
|
for sname in tqdm(simple_dirs, desc="Iterating simple/ directory"):
|
||||||
sd = basedir / "simple" / sname
|
sd = basedir / "simple" / sname
|
||||||
@ -1148,7 +1161,7 @@ def verify(
|
|||||||
if str(file) not in ref_set:
|
if str(file) not in ref_set:
|
||||||
logger.info("removing unreferenced file %s", file)
|
logger.info("removing unreferenced file %s", file)
|
||||||
file.unlink()
|
file.unlink()
|
||||||
|
|
||||||
logger.info("Verification finished. Success: %s", success)
|
logger.info("Verification finished. Success: %s", success)
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user