This commit is contained in:
David Allemang
2026-01-25 00:32:28 -05:00
parent e24ae6c457
commit fc7db2706a

View File

@@ -47,6 +47,16 @@ class Args:
), ),
) )
alias: str
_p.add_argument(
'-a',
"--alias",
default=None,
help=(
"If only one SRC is provided, alias the image with this name. This is not supported for multiple upload."
),
)
tags: list[str] tags: list[str]
_p.add_argument( _p.add_argument(
"-t", "-t",
@@ -81,6 +91,7 @@ class Args:
view: bool view: bool
_p.add_argument( _p.add_argument(
"-v",
"--view", "--view",
action="store_true", action="store_true",
default=False, default=False,
@@ -138,6 +149,21 @@ def main() -> None:
urls.append(url := url) urls.append(url := url)
print(f"- {url} ({stat} {SRCNAME.get(src, src)})") print(f"- {url} ({stat} {SRCNAME.get(src, src)})")
if args.alias and len(args.srcs) == 1:
alias = mnt.joinpath(f"{args.alias}.webp")
alias.parent.mkdir(parents=True, exist_ok=True)
if not (exists := alias.exists()) or args.reupload:
stat = "realiased" if exists else "aliased"
if exists:
alias.unlink()
os.link(dst, alias) # transform_symlinks are bugged with sshfs, so use hardlink.
else:
stat = "skipped"
alias_url = urljoin(base_url, str(alias.relative_to(mnt)))
print(f" {alias_url} ({stat})")
for tag in args.tags: for tag in args.tags:
tag_dst = mnt.joinpath(tag, dst.name) tag_dst = mnt.joinpath(tag, dst.name)
tag_dst.parent.mkdir(parents=True, exist_ok=True) tag_dst.parent.mkdir(parents=True, exist_ok=True)