Fix WebDAV cleanup and resize notification QR
This commit is contained in:
@@ -261,7 +261,8 @@ def _remote_paths_from_published_url(
|
|||||||
# 公开地址允许带路径前缀;该前缀是下载路由的一部分,不属于远端文件路径。
|
# 公开地址允许带路径前缀;该前缀是下载路由的一部分,不属于远端文件路径。
|
||||||
mode = upload_config.get("mode")
|
mode = upload_config.get("mode")
|
||||||
if mode == "webdav":
|
if mode == "webdav":
|
||||||
base_url = upload_config.get("webdav", {}).get("public_url", "")
|
webdav = upload_config.get("webdav", {})
|
||||||
|
base_url = webdav.get("public_url", "")
|
||||||
else:
|
else:
|
||||||
base_url = upload_config.get("oss", {}).get("base_url", "")
|
base_url = upload_config.get("oss", {}).get("base_url", "")
|
||||||
base = urlparse(base_url)
|
base = urlparse(base_url)
|
||||||
@@ -270,6 +271,19 @@ def _remote_paths_from_published_url(
|
|||||||
if base_path and remote_path.startswith(f"{base_path}/"):
|
if base_path and remote_path.startswith(f"{base_path}/"):
|
||||||
remote_path = remote_path[len(base_path) + 1:]
|
remote_path = remote_path[len(base_path) + 1:]
|
||||||
|
|
||||||
|
# Historical WebDAV links may contain the configured directory twice, e.g.
|
||||||
|
# public_url=/iOS plus base_path=/iOS produced /iOS/iOS/file. If public_url
|
||||||
|
# was later corrected to the site root, the current prefix stripping above
|
||||||
|
# cannot remove the old extra segment. Files were still uploaded only once
|
||||||
|
# under base_path, so collapse that duplicated prefix when recovering the
|
||||||
|
# remote path for deletion.
|
||||||
|
if mode == "webdav":
|
||||||
|
configured_path = str(webdav.get("base_path") or "/").strip("/")
|
||||||
|
if configured_path:
|
||||||
|
duplicated_prefix = f"{configured_path}/{configured_path}/"
|
||||||
|
if remote_path.startswith(duplicated_prefix):
|
||||||
|
remote_path = remote_path[len(configured_path) + 1:]
|
||||||
|
|
||||||
path = Path(remote_path)
|
path = Path(remote_path)
|
||||||
if path.suffix == ".zip":
|
if path.suffix == ".zip":
|
||||||
return [str(path)]
|
return [str(path)]
|
||||||
@@ -470,7 +484,10 @@ def publish_ipa(config: dict, ipa_path: Path, build_dir: Path) -> tuple[str, str
|
|||||||
import qrcode
|
import qrcode
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
raise DistributionError("未安装 qrcode,请重新执行 ./deploy.sh build") from exc
|
raise DistributionError("未安装 qrcode,请重新执行 ./deploy.sh build") from exc
|
||||||
qrcode.make(urls[".html"]).save(qr_path)
|
qr = qrcode.QRCode(box_size=5, border=4)
|
||||||
|
qr.add_data(urls[".html"])
|
||||||
|
qr.make(fit=True)
|
||||||
|
qr.make_image(fill_color="black", back_color="white").save(qr_path)
|
||||||
urls.update(uploader(upload, [(qr_path, qr_remote)]))
|
urls.update(uploader(upload, [(qr_path, qr_remote)]))
|
||||||
return urls[".html"], urls[".png"]
|
return urls[".html"], urls[".png"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user