mirror of
https://git.ari.lt/ari.lt/blog.ari.lt.git
synced 2025-02-04 09:39:25 +01:00
update @ Sun Dec 15 18:59:14 EET 2024
Signed-off-by: Ari Archer <ari@ari.lt>
This commit is contained in:
parent
b5036a3d89
commit
a526218733
1 changed files with 13 additions and 13 deletions
|
@ -479,6 +479,16 @@ def ctimer() -> float:
|
||||||
return code_timer() if NCI else 0
|
return code_timer() if NCI else 0
|
||||||
|
|
||||||
|
|
||||||
|
def update_media(config: dict[str, typing.Any]) -> int:
|
||||||
|
"""update media.json"""
|
||||||
|
|
||||||
|
with open("media/media.json", "w") as fp:
|
||||||
|
log("dumping media.json")
|
||||||
|
json.dump(MEDIA_INDEX, fp, indent=config["indent"])
|
||||||
|
|
||||||
|
return OK
|
||||||
|
|
||||||
|
|
||||||
def log(msg: str, clr: str = LOG_CLR) -> int:
|
def log(msg: str, clr: str = LOG_CLR) -> int:
|
||||||
if NCI:
|
if NCI:
|
||||||
print(
|
print(
|
||||||
|
@ -1730,8 +1740,6 @@ def blog(config: dict[str, typing.Any]) -> int:
|
||||||
def media(config: dict[str, typing.Any]) -> int:
|
def media(config: dict[str, typing.Any]) -> int:
|
||||||
"""add media"""
|
"""add media"""
|
||||||
|
|
||||||
assert config is config, "Unused"
|
|
||||||
|
|
||||||
if os.path.exists("licenses.json"):
|
if os.path.exists("licenses.json"):
|
||||||
with open("licenses.json", "r") as fp:
|
with open("licenses.json", "r") as fp:
|
||||||
licenses: tuple[str, ...] = json.load(fp)
|
licenses: tuple[str, ...] = json.load(fp)
|
||||||
|
@ -1875,7 +1883,7 @@ def media(config: dict[str, typing.Any]) -> int:
|
||||||
|
|
||||||
lnew(f"media {hash_hex} created")
|
lnew(f"media {hash_hex} created")
|
||||||
|
|
||||||
return OK
|
return update_media(config)
|
||||||
|
|
||||||
|
|
||||||
@cmds.new
|
@cmds.new
|
||||||
|
@ -1897,14 +1905,12 @@ def lsmedia(config: dict[str, typing.Any]) -> int:
|
||||||
def rmmedia(config: dict[str, typing.Any]) -> int:
|
def rmmedia(config: dict[str, typing.Any]) -> int:
|
||||||
"""remove media"""
|
"""remove media"""
|
||||||
|
|
||||||
assert config is config, "Unusued"
|
|
||||||
|
|
||||||
for mdx in select_medias():
|
for mdx in select_medias():
|
||||||
imp(f"Removing media {mdx}")
|
imp(f"Removing media {mdx}")
|
||||||
os.remove(f"media/{mdx}.{MEDIA_INDEX[mdx]['ext']}")
|
os.remove(f"media/{mdx}.{MEDIA_INDEX[mdx]['ext']}")
|
||||||
del MEDIA_INDEX[mdx]
|
del MEDIA_INDEX[mdx]
|
||||||
|
|
||||||
return OK
|
return update_media(config)
|
||||||
|
|
||||||
|
|
||||||
@cmds.new
|
@cmds.new
|
||||||
|
@ -1945,7 +1951,7 @@ def purgemedia(config: dict[str, typing.Any]) -> int:
|
||||||
imp(f"Removing unindexed media {pid}")
|
imp(f"Removing unindexed media {pid}")
|
||||||
os.remove(f"media/{file}")
|
os.remove(f"media/{file}")
|
||||||
|
|
||||||
return OK
|
return update_media(config)
|
||||||
|
|
||||||
|
|
||||||
@cmds.new
|
@cmds.new
|
||||||
|
@ -2031,12 +2037,6 @@ def main() -> int:
|
||||||
log(f"dumping config to {config.name!r}")
|
log(f"dumping config to {config.name!r}")
|
||||||
json.dump(cfg, config, indent=cfg["indent"] if NCI else None)
|
json.dump(cfg, config, indent=cfg["indent"] if NCI else None)
|
||||||
|
|
||||||
# Update media.json
|
|
||||||
|
|
||||||
with open("media/media.json", "w") as fp:
|
|
||||||
log("dumping media.json")
|
|
||||||
json.dump(MEDIA_INDEX, fp, indent=cfg["indent"])
|
|
||||||
|
|
||||||
log(f"goodbye world, return {code}, total {ctimer() - main_t} s")
|
log(f"goodbye world, return {code}, total {ctimer() - main_t} s")
|
||||||
|
|
||||||
return code
|
return code
|
||||||
|
|
Loading…
Add table
Reference in a new issue