forked from wrenn/wrenn
This commit is contained in:
@ -3,6 +3,7 @@ import sys
|
||||
|
||||
from wrenn import Capsule, StreamExitEvent, StreamStderrEvent, StreamStdoutEvent
|
||||
from wrenn._git import GitCommandError
|
||||
from wrenn.models import FileEntry
|
||||
|
||||
GO_VERSION = os.getenv("GO_VERSION", "1.25.8")
|
||||
REPO_URL = "https://git.omukk.dev/wrenn/wrenn.git"
|
||||
@ -83,7 +84,7 @@ def build_app(capsule: Capsule) -> bool:
|
||||
def download_artifacts(capsule: Capsule) -> bool:
|
||||
remote_dir = f"{REPO_DIR}/builds"
|
||||
entries = capsule.files.list(remote_dir, depth=1)
|
||||
files = [e for e in entries if not e.is_dir]
|
||||
files = [e for e in entries if e.type != "directory"]
|
||||
|
||||
if not files:
|
||||
print("FAIL [download]: no files found in builds/", file=sys.stderr)
|
||||
@ -93,15 +94,16 @@ def download_artifacts(capsule: Capsule) -> bool:
|
||||
os.makedirs(local_dir, exist_ok=True)
|
||||
|
||||
for entry in files:
|
||||
remote_path = f"{remote_dir}/{entry.name}"
|
||||
local_path = os.path.join(local_dir, entry.name)
|
||||
print(f"Downloading {entry.name} ({entry.size or '?'} bytes)...")
|
||||
name = entry.name or "unknown"
|
||||
remote_path = f"{remote_dir}/{name}"
|
||||
local_path = os.path.join(local_dir, name)
|
||||
print(f"Downloading {name} ({entry.size or '?'} bytes)...")
|
||||
|
||||
with open(local_path, "wb") as f:
|
||||
for chunk in capsule.files.download_stream(remote_path):
|
||||
f.write(chunk)
|
||||
|
||||
print(f"OK [download {entry.name}]")
|
||||
print(f"OK [download {name}]")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user