Skip to content

tools/sb3.py --patch removes all assets from .sb3 files #346

Description

@aspizu

Repro

tmp=$(mktemp -d /tmp/goboscript-sb3patch-assets-XXXXXX)
printf 'costumes "blank.svg";\n\n' > "$tmp/stage.gs"
printf '<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>\n' > "$tmp/blank.svg"
cargo run --quiet -- build "$tmp"
sb3="$tmp/$(basename "$tmp").sb3"
python3 tools/sb3.py "$sb3"
python3 - <<'PY' "$sb3" before
import sys, zipfile
with zipfile.ZipFile(sys.argv[1]) as z:
    print(sys.argv[2], sorted(z.namelist()))
PY
python3 tools/sb3.py --patch "$sb3"
python3 - <<'PY' "$sb3" after
import sys, zipfile
with zipfile.ZipFile(sys.argv[1]) as z:
    print(sys.argv[2], sorted(z.namelist()))
PY

Observed:

before ['19fc47764555c248fbb3cca5465be39b.svg', 'project.json']
after ['project.json']

The docs recommend this workflow for editing generated project.json, but --patch opens the .sb3 in write mode and writes only project.json. Costume and sound assets are dropped, leaving a project that references files no longer present in the archive.

Expected

--patch should replace only project.json and preserve all other zip entries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions