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