Skip to content

Put folders into a lease's folder, and copy files into and out of an app's container #1636

Open
0 of 4 issues completed

Description

@V3RON

Request: #945

Problem

A remote caller cannot install an iOS app it built: a simulator .app is a folder, a lease's folder takes single files, and nothing unpacks one (ADR 0067). simlock files put MyApp.app is refused, and the notice a failed simctl install prints says to use agent-device.

Nothing puts files into an app's data container, or reads them back. budgie's e2e suite (budgie-at/budgie#1867) built a helper simulator app (E2EDrop) and sends fixtures as base64 raw-deflate on exec stdin, unpacked with simctl spawn <helper> untar <dir>.

Uploading a build once for many leases was part of this issue and is now #1998.

Who it is for

A CI run or an agent on another machine that leases a device from a farm, installs the build it made, and puts test fixtures into the app.

Outcome

  • simlock files put <folder> puts a folder into the lease's folder on its worker, .app included, and simlock simctl install MyApp.app installs it.
  • simlock files get <folder> brings a folder back, one a command wrote included.
  • simlock files push copies a file or folder from the lease's folder into an app's data container, and simlock files pull copies one out of it, on an iOS simulator, an Android emulator and an Android phone, with no helper app.
  • The same four over HTTP, on a worker and through a gateway.

How it works for the user

flowchart TD
  A[files put MyApp.app] -->|tar stream| L[Lease folder on the worker]
  A -->|entry refused, or cut| N[Nothing stored, error]
  L -->|simctl install MyApp.app| I[App installed]
  L -->|files push fixtures --app id --to dir| C[App's data container]
  C -->|files pull dir/app.db --app id| L
  L -->|files get app.db or folder| H[Caller's machine]
  L -->|push on an iPhone| U[APP_FILES_UNSUPPORTED]
  L -->|push to an app that is not installed| X[UNKNOWN_APP]
Loading

Before:

$ simlock files put build/MyApp.app
{"error":{"code":"USAGE","message":"build/MyApp.app is a folder; a folder cannot be uploaded yet (#1636)"}}
$ simlock simctl install ./MyApp.app
… simctl's own error …
{"notice":"./MyApp.app is a folder on this machine, and the command ran on the worker; a folder cannot be uploaded yet (#1636): install it with agent-device, or from a path on the worker"}
$ simlock files push fixtures --app com.acme.app --to Documents
{"error":{"code":"USAGE","message":"Unknown files command: push …"}}

After:

$ simlock files put build/MyApp.app
{"lease":"lse_3b9d…","name":"MyApp.app","size":48213760,"kind":"folder"}
$ simlock simctl install MyApp.app
$ simlock files put fixtures
{"lease":"lse_3b9d…","name":"fixtures","size":70000000,"kind":"folder"}
$ simlock files push fixtures --app com.acme.app --to Documents
{"lease":"lse_3b9d…","name":"fixtures","app":"com.acme.app","to":"Documents"}
$ simlock files pull Documents/app.db --app com.acme.app
{"lease":"lse_3b9d…","name":"app.db","size":40960,"kind":"file"}
$ simlock files get app.db -o app.db
$ simlock files get fixtures -o back
$ simlock files get fixtures -o back
{"error":{"code":"USAGE","message":"back exists; name a folder that does not exist with -o"}}
$ simlock files push fixtures --app com.acme.nope --to Documents
{"error":{"code":"UNKNOWN_APP","message":"com.acme.nope is not installed on the leased device"}}
$ simlock simctl install ./Other.app
… simctl's own error …
{"notice":"./Other.app is on this machine, but the command ran on the worker; upload it with `simlock files put ./Other.app` and name it by its file name"}

Examples

Container paths (--to, and the path of pull), always relative to the app's data container.

Path Today push --to pull
Documents no such command accepted accepted
Library/Application Support — accepted accepted
it's/ä — accepted accepted
. — accepted: the container itself refused
Documents/ — accepted, same as Documents accepted, same as Documents
/tmp/x, ../x, a/../b, empty — refused, BAD_REQUEST refused, BAD_REQUEST
a path with a link in it that leads out of the container (iOS) — refused, BAD_REQUEST refused, BAD_REQUEST

What push writes:

In the lease's folder --to Documents Written
folder fixtures with a.txt and sub/b.txt Documents/a.txt, Documents/sub/b.txt
file seed.db Documents/seed.db
a file already in the container under that name replaced
other files already there kept

Entries of a folder sent to the worker, or packed by the CLI:

Entry Result
file, with or without its executable bit kept, bit included
folder, empty or not kept
symbolic link to a path inside the folder kept
symbolic link that leads out, or is absolute refused by a put, left out of a get, a push and a pull
a \ in the name, a name over 255 bytes, a path over 1024 bytes the same
hard link, device, socket, FIFO the same
../x, /x in a tar that arrives refused, always
symbolic link on Windows, which may not create one the same as a link that leads out
._name (macOS metadata that tar adds) and the top entry ./ left out

Names of a folder in the lease's folder follow the rule of a file's name: MyApp.app and fixtures are accepted, .hidden, my folder and . are refused before anything is sent and need --name.

What could go wrong

  • A user pushes fixtures into a running app, which overwrites them or reads half of them. Likely at first; the docs say to stop the app before.
  • An Android user pushes into a release build and is refused, because run-as works only for a debuggable app. Likely; the error carries run-as's own words.
  • A push that fails part way leaves some files in the container. Unlikely; run it again.
  • A folder with a link out of it is refused, where a user expected it to be followed. Unlikely.
  • A folder pushed from or to a Windows machine loses its executable bits. Likely there; a simulator app installs without them.
  • An Android device has no room for the temporary copy a push or pull makes on it. Unlikely; adb's own message says so.

Words used

  • Lease folder: the folder on the worker that holds a lease's files; commands run in it. Example: after simlock files put MyApp.app, simlock simctl install MyApp.app.
  • Data container: the private folder of one installed app on the device. Example: on iOS it holds Documents and Library; on Android it is /data/data/<package> and holds files and databases.
  • App id: the bundle id on iOS, the package name on Android. Example: com.acme.app.
  • Tar stream: a folder written as one run of bytes, as tar does. Example: tar -cf - -C MyApp.app .
  • Archive: such a tar kept as one file, for the time of a push or pull.
  • Debuggable app: an Android build with android:debuggable, as a debug build has. run-as runs only as such an app.
  • Farm: a worker or gateway reached by its HTTP address.

Non-goals

Completion conditions

  • From another machine, simlock files put MyApp.app and then simlock simctl install MyApp.app install and launch a simulator app on a worker.
  • A folder put and got back has the same files, contents, executable bits and inner links.
  • A folder a command wrote into the lease's folder shows in simlock files list and comes back with simlock files get.
  • A refused or cut folder leaves nothing stored.
  • simlock files push and pull move files into and out of an app's data container on a real simulator and a real emulator.
  • push and pull on an iPhone, to an unknown app, to a path outside the container and to a non-debuggable Android app fail with their own errors.
  • All of it works through a gateway.
  • Uploading, downloading, listing and deleting a single file behaves as on main, except that a reply carries kind.

Open questions

none

Decisions

  • ADR 0100 — A lease's folder holds folders, and Simlock copies them into and out of an app's container (#1999): a folder is a tar stream between the ends, one port reads and writes trees, the driver copies an archive with adb push and adb pull or on the simulator's disk, the device's state is untouched.
  • ADR 0067 — A lease has a file folder on its worker: names, limits, the files relay target and lease end stay as they are.
  • ADR 0081 — A remote caller speaks the daemon protocol over one WebSocket path: file routes stay HTTP, for simlock files in remote mode.
  • Decided with the maintainer in the session of 2026-11-30: the shared upload is its own feature, Upload a build once and install it on many leases #1998.
  • Decided with the maintainer in the session of 2026-11-30: a folder is packed when sent and unpacked on the worker, and comes back the same way.
  • Decided with the maintainer in the session of 2026-11-30: Simlock writes into the container itself, with push and pull, on everything but real iPhones and iPads.
  • Decided with the maintainer in the session of 2026-11-30: no file goes through adb shell. A push sends one archive with adb push and the device unarchives it; a pull archives on the device and fetches it with adb pull. Measured with a debuggable app on the Android 15 default and the Android 16 Play emulator images: every byte the same, links and empty folders kept. adb push of the folder itself drops empty folders and fails on a link.
  • Decided in the session: the worker archives the folder again for a push, because the lease's folder holds it unarchived (simctl install needs that) and a command may have changed it since.
  • Decided in the session: file calls, push and pull included, do not count as use for the idle end of End a lease after an operator-set time without device use #1899, because moving files is not using the device and the command that follows counts.
  • Decided in the session: copies on one Android device run one after another in one temporary folder of a fixed name, because the next copy then removes what a killed daemon left.
  • Decided in the session: tar, not zip, because a tar can be unpacked as it arrives and a zip's index is at its end.
  • Decided in the session: tar-stream 3.1.7 is added as a runtime dependency (its dependencies are b4a, fast-fifo and streamx, 396 KB installed) and its pack and extract are used (they read the long names of macOS's and Android's tar); Simlock writes each entry itself, because three system tar programs answer an unsafe entry in three ways. It is loaded on first use.
  • Decided in the session: the routes hang under /files/{name}/, because a new lease route name would also have to be refused as a module's name.
  • Decided in the session: push of a folder copies what is in it, and of a file the file under its name, because a user names the target folder and fixtures belong in it directly.
  • Decided in the session: pull lands in the lease's folder and get fetches it, because one transfer path then serves both.
  • Decided in the session: push and pull end after 300 s, because a gateway's relay waits 330 s for an answer; the CLI waits 360 s.
  • Decided in the session: files are written with mode 755 when the sender's entry was executable and 644 otherwise, folders 755, under the lease folder's 700, because adb push copies the mode to the device.
  • Decided in the session: an entry Simlock does not carry (a link that leads out, a \ in a name, a socket) fails a put and is left out of a get, a push and a pull, because the sender can fix its own folder and a reader cannot fix what a command or an app wrote.
  • Decided in the session: 2 GiB bounds a whole put folder and a whole pull, because both are one stream, as a file is.
  • Decided in the session: on Windows folders work without links and executable bits, because Windows has no such bit and lets only administrators create links.
  • Decided in the session: a push or pull whose caller goes away runs to its end, because the bytes are already on the worker and 300 s bound it.

Behaviours

Id Behaviour (invoker, action, what it sees) Seam Cases Task
B1 An HTTP caller puts a tar to I3; sees 201 with kind folder and the sum of the stored files' sizes, and the tree is in the lease's folder createLeaseFiles handle over MemoryFilesystem one file; nested and empty folders; entries for folders that are not empty, and none for them; executable and not; inner link; long path (pax, and GNU as Android's tar writes it); a pax global header; ._x and ./ left out; empty tar; replaces a folder, a file, another spelling; a file put replaces a folder #2004
B2 An HTTP caller puts a tar that is refused; sees the error of I2 or I3 and the target is as before, with no temporary folder left same each refused row of the Entries example; a link where the filesystem refuses to create one; over 100,000 entries; body over 2 GiB (declared, streamed); lease full; disk low; body not a tar; body cut inside an entry; 330 s silence; second put to the name, by file or folder; lease ends during it; Content-Length over 2 GiB at a gateway #2004
B3 A caller lists and deletes; the list has files and folders with kind and size, a delete removes either same, and createHttpApp for the route file; folder put; folder a command wrote; a link and a badly named folder are not listed; delete of a folder, of another spelling, of an unknown name #2004
B4 simlock files put <folder> packs and sends it and prints the reply with lease and kind; put of a file prints kind file runCli with a fake HTTP stream folder; empty folder; trailing /; --name; . and my folder without --name (exit 2, I5's message, nothing sent); link that leads out, \ in a name, socket (exit 2, nothing sent); the farm's refusal keeps its code; 60 s with no byte; a folder unreadable part way; a file that shrinks while it is read #2004
B5 A failed remote simctl or adb that named a local folder prints the same notice a local file gets runCli folder; file as today #2004
B6 A gateway relays the put of a folder to the lease's worker, streaming, and its refusals carry the caller's lease id gateway and worker with a fake driver, as relay-gateway-files.e2e.test.ts put; LEASE_FILES_FULL; worker not connected #2004
B7 simlock files put MyApp.app, then simlock simctl install MyApp.app and a launch, on a real simulator slow lane one built simulator app #2004
B8 An HTTP caller gets a folder through I4 and sees its tar; a get of a folder through the file route sees NOT_A_FILE, and of a file through I4 NOT_A_FOLDER createLeaseFiles handle; the dispatcher for device.exec folder; empty folder; inner link kept; link out, socket, \ in a name left out; unknown name; another spelling; a file that vanishes or shrinks ends the body with an error; a file that grows is sent at its first size; the caller goes away; stdinFile naming a folder sees NOT_A_FILE #2005
B9 simlock files get <folder> writes the folder at -o or ./<name>, whole or not at all runCli default target; -o; target exists (exit 2, message of How it works); .part left by another run (exit 1, kept); a cut body leaves no folder; a link this machine cannot create is left out; an entry refused by I1 (REMOTE_UNREACHABLE, nothing written); a file name still goes to stdout or -o as today #2005
B10 A gateway relays the get of a folder, streaming as B6 folder; worker's UNKNOWN_FILE #2005
B11 An HTTP caller pushes a stored file or folder through I7; sees 200, the driver was handed an archive of it, and no archive is left createLeaseFiles handle with a fake AppFiles folder's contents; empty folder; one file; link out left out; each refused path of Examples; Documents/ echoed as Documents; a bad app id; a body that is no JSON, too long or without a field; unknown stored name; no driver capability or an iPhone (APP_FILES_UNSUPPORTED); UNKNOWN_APP; APP_FILES_FAILED; a file that shrinks while it is archived; disk low; 300 s (answered though the driver has not returned); caller goes away (runs on); lease ends during it #2006
B12 The iOS driver writes the archive into the simulator's data container iOS driver with ScriptedProcessRunner and MemoryFilesystem new and existing folders; a file replaced; others kept; app unknown (exit 2); (null) printed; another simctl failure; link in the path that leads out; . ; aborted; physical device unsupported #2006
B13 The Android driver pushes the archive and has the device unarchive it, on an emulator and a phone, and removes its temporary folder after a success and after a failure Android driver with ScriptedProcessRunner emulator; phone; path with a space and a quote; an archive with no entry (the folder is made, nothing is pushed); what an earlier copy left is removed first; unknown package; package that is no application; not debuggable; adb push fails; unarchiving fails; the removal fails (the copy still succeeds); emulator without a serial; phone behind a closed gate; a step that times out; aborted; two copies on one device run one after the other, on two devices together #2006
B14 simlock files push prints the reply of How it works runCli success; an answer after 200 s; none after 360 s (REMOTE_UNREACHABLE); missing --app or --to (exit 2); a name that is no file name (exit 2, nothing sent); BAD_REQUEST exits 2, each other error of I7 keeps its code and exits 1 #2006
B15 A gateway relays a push, and its refusals carry the caller's lease id as B6 success; UNKNOWN_APP; worker not connected #2006
B16 simlock files push then a read in the container, on a real simulator and a real emulator with a debuggable app slow lane iOS; Android; on Android a folder with files/ in it to ., twice, after which the container and files have the modes they had #2006
B17 An HTTP caller pulls a path through I9; sees 201 with kind and size, the file or folder is in the lease's folder, and no archive is left createLeaseFiles handle with a fake AppFiles file; folder; empty folder; replaces; link out left out; an archive cut inside an entry (APP_FILES_FAILED); path missing (UNKNOWN_FILE); lease full, disk low, over 2 GiB; second writer of the name; . refused; a bad body; the errors of B11; nothing stored after any failure #2007
B18 The iOS driver archives a container path iOS driver, fakes file; folder; missing; link in the path that leads out; unknown app; over the size the caller admits; aborted #2007
B19 The Android driver archives a container path on the device and fetches it with adb pull Android driver with ScriptedProcessRunner file; folder; path with a space and a quote; top-level path; missing path; unknown package; not debuggable; tar fails part way; a size that is not a number; over the size the caller admits (nothing is fetched); adb pull fails; aborted; the temporary folder is removed after each #2007
B20 simlock files pull <path> --app <id> stores it under the path's last part, or --name, and prints the reply runCli file; folder; --name; Documents/; a last part that is no valid name (exit 2, I10's message); missing --app (exit 2); none after 360 s; BAD_REQUEST exits 2, each other error keeps its code and exits 1 #2007
B21 A gateway relays a pull as B6 success; UNKNOWN_FILE #2007
B22 simlock files pull and get return bytes a push put there, on a real simulator and a real emulator slow lane iOS; Android #2007

Stored state

Id What and where Created, changed, deleted by Listed or swept by A restart mid-step leaves Schema step Task Used by
S1 A folder <dataDir>/lease-files/<hex(lease id)>-<grantedAt>/<name>/ I3 and I9 unpack beside it (S2), remove what held the name in any spelling and rename; DELETE removes it; the lease's end removes it with the lease's folder list (B3); #folderBytes counts it; startup's sweep removes a dead lease's whole folder either the old or no entry under the name, and S2 none #2004 #2005, #2006, #2007
S2 .upload-<id> as a folder, and .upload-<id>.tar as a file, in the lease's folder I3 and I9 create the folder, I7 and I9 the archive; a success renames the folder to S1 (for a pulled file, the file in it) and removes the rest; a failure removes both, after its writes have stopped sweep removes every .upload- entry at startup; #folderBytes skips them and counts the running upload's bytes instead: the stream's of I3, the archive's of I9, none of I7 the temporary entries, removed by the next start none #2004 #2006, #2007
S3 <target>.part on the caller's machine, a folder files get creates it, renames it to the target, removes it on a failure — the .part folder; the next get to that target fails until the user removes it, as for a file today none #2005 —
S4 /data/local/tmp/simlock-app-files/ on an Android device, with one archive the Android driver creates it for one copy and removes it after, whatever the copy's end the next copy on the device removes it first; a virtual device goes with its lease the folder, on a phone, until the next copy none #2006 #2007

Interfaces

Id What Shape and bounds Errors and limits Where Task Used by
I1 Port TreeArchive check(path, links) walks folder path and rejects on the first entry refuse refuses. pack(path, { links: "refuse" | "skip", top: boolean }): ReadableStream<Uint8Array>: with top, the file or folder path under its own name; without, what is in folder path. A folder has an entry of its own only when it is empty, and what is in path never has one for path itself, so unarchiving on Android changes the mode of no folder that is there, but of one that is empty in the archive (755). unpack(root, stream, { links, strip: 0 | 1 }): Promise<{ size, top?: { name, kind } }> writes into folder root, which exists; size is the sum of the files' sizes; strip: 1 drops each path's first part and reports it in top (a single file is then written as root/<its name>). Reads and writes through Filesystem; loads tar-stream on the first call. Links are made after every file. An existing file or link in the way is removed first; an existing folder is kept. A packed file is read to exactly the size its header gave. links rules every entry of the Examples' shared rows TreeEntryError { entry, reason }, reason one of leads outside the folder (always refused), is a link that leads outside the folder, is a link, which this machine cannot store (the filesystem answers EPERM), is not a file, folder or link, has a name that is too long, has a \ in its name, changed while it was read (always refused), is over the limit of 100000 entries (always refused); TreeFormatError for bytes that are no tar or end inside an entry. Any other error is the filesystem's. Holds one entry's header and one chunk, never a file src/ports/tree-archive.ts, adapter NodeTreeArchive(filesystem); tests use it over MemoryFilesystem, so it has no fake #2004 #2005, #2006, #2007
I2 A lease file's reply { name, size, kind: "file" | "folder" } in PUT and in each row of the list; a folder's size is the sum of its files' — src/http/lease-declarations.ts, store.ts #2004 #2005, #2007
I3 PUT /v1/leases/{id}/files/{name}/folder body: a tar of what is in the folder, no top folder; unpacked with links: "refuse", strip: 0 into S2; reply 201, I2. Relayed as /files/leases/{id}/{name}/folder BAD_REQUEST 400 Folder <name>: <entry> <reason> (I1's TreeEntryError) or The body is not a tar archive (TreeFormatError); FILE_TOO_LARGE Folder <name> is over the 2 GiB limit for one folder when the body passes 2 GiB; LEASE_FILES_FULL, INSUFFICIENT_DISK_SPACE, FILE_BUSY, UPLOAD_STALLED, UNKNOWN_LEASE as a file's. A lease's bytes count the stream's bytes while it runs src/lease-files/, src/http/, src/daemon/gateway-lease-files.ts #2004 #2005
I4 GET /v1/leases/{id}/files/{name}/folder 200 application/octet-stream (ADR 0067 §4), Cache-Control: no-store, no length, I1 pack with links: "skip", top: false. Relayed as I3 new codes, kind domain, exit 1: NOT_A_FILE 409 <name> is a folder, not a file from openFile (the file route and stdinFile), NOT_A_FOLDER 409 <name> is a file, not a folder here, details { name }; bumps the protocol by one. UNKNOWN_FILE, UNKNOWN_LEASE src/lease-files/, src/http/, src/contract/errors.ts #2005 —
I5 simlock files put <folder> the name is --name, else the folder's own; I1 check, then pack with links: "refuse", top: false, sent chunked to I3 with the transfer rule of files put (60 s without a byte) exit 2 <name> is not a file name a lease can hold; pass --name and <path>: <entry> <reason> (I1), before anything is sent; exit 1 with the latter for an entry that fails while it is sent src/cli/commands/files.ts #2004 —
I6 Driver capability AppFiles (optional Driver.appFiles), beside deviceTcp supports(device): boolean; write(device, { app, to, archive }, signal): Promise<void>: archive is the path of a tar on the worker's disk, app matches [A-Za-z0-9][A-Za-z0-9._-]{0,254}, to is normalized, relative, no .., . for the container. iOS: simctl get_app_container <udid> <app> data (30 s), then I1 unpack with links: "skip" into <container>/<to>, made if missing. Android, each step one runAdbOn (X10), T the folder S4: shell "run-as <app> sh -c :" (30 s); shell "rm -rf T && mkdir T" (30 s); push <archive> T/app.tar (300 s); shell "run-as <app> sh -c 'umask 022; mkdir -p \"$0\" && tar -x -C \"$0\" -f T/app.tar' '<to>'" (300 s) with ' in to quoted as '\'', the push skipped and && tar … left out for an archive of 1024 bytes or fewer, which holds no entry and which Android's tar refuses; at the end, whatever happened and without signal, shell "rm -rf T" (30 s), whose failure is logged. Copies on one Android device run one after another. Absent on a driver: the catalog answers unsupported AppFilesError { code, message }. UNKNOWN_APP: iOS exit 2, or an answer that does not start with /; Android stderr with unknown package or not an application. BAD_REQUEST: an iOS path whose real path leaves the container. APP_FILES_FAILED: every other non-zero exit, with stderr, else stdout, its first 200 characters. An aborted signal ends the running step and rejects with its reason src/core/app-files.ts, driver-catalog.ts, src/drivers/ios/app-files.ts, src/drivers/android/app-files.ts; fake FakeAppFiles in core/testing #2006 #2007
I7 POST /v1/leases/{id}/files/{name}/push and simlock files push <name> --app <id> --to <dir> [--lease <id>] body { app, to }, JSON of at most 16 KiB, read and checked by the lease files' handler on every path; to 1 to 1024 characters, no control character; to is normalized (no trailing /); the stored entry is archived by I1 pack with links: "skip", a folder without top, a file with; reply 200 { name, app, to }, to as normalized; the CLI adds lease and waits 360 s for the answer. Relayed as /files/leases/{id}/{name}/push new codes, kind domain, exit 1: UNKNOWN_APP 404 <app> is not installed on the leased device details { app }; APP_FILES_UNSUPPORTED 409 App files need an iOS simulator, an Android emulator or an Android phone details {}; APP_FILES_FAILED 502 Copying into <app> failed: <I6's message, or I1's entry and reason> details { app }; bumps the protocol by one. BAD_REQUEST (exit 2) <to> is not a path inside the app's container, <app> is not an app id, The body must be JSON with app and to; UNKNOWN_FILE, INSUFFICIENT_DISK_SPACE, UNKNOWN_LEASE. The CLI refuses a name outside the file-name rule, exit 2, <name> is not a file name a lease can hold. 300 s from the request's arrival at the worker, then APP_FILES_FAILED Copying into <app> did not finish in 300 s, answered without waiting for the driver, which is aborted and whose end the lease's end waits for src/lease-files/, src/http/, src/contract/errors.ts, src/cli/commands/files.ts #2006 #2007
I8 Filesystem.symlink(target, path) creates a link at path, its target as given; fails EEXIST when something is there the platform's errno, EPERM on a Windows account that may not create links src/ports/filesystem.ts: NodeFilesystem and MemoryFilesystem, whose links then resolve a relative target against their own folder and whose defineOther(path) puts a socket there #2004 #2005, #2006, #2007
I9 AppFiles.read and POST /v1/leases/{id}/files/{name}/pull read(device, { app, from, archive, onBytes(total) }, signal): Promise<void> writes the new file archive: a tar with one top entry, the last part of from; onBytes is told the archive's size before those bytes are written and stops the copy by throwing. iOS: the container as in I6, then I1 pack with links: "skip", top: true. Android, steps and queue as I6: run-as <app> sh -c :; shell "run-as <app> sh -c 'test -e \"$0\" || exit 44' '<from>'" (30 s); rm -rf T && mkdir T; shell "run-as <app> tar -c -C '<parent, . for none>' '<last part>' > T/app.tar" (300 s); shell "stat -c %s T/app.tar" (30 s), its number to onBytes; pull T/app.tar <archive> (300 s); rm -rf T. The route: body { app, from }, bounds and checks of I7, . refused; reply 201, I2; the archive is unpacked with strip: 1, links: "skip" into S2 I6's errors, and UNKNOWN_FILE from read for exit 44 or a path that is not there on iOS; a size that is not a number is APP_FILES_FAILED. The route: I7's codes with Copying out of <app> … and The body must be JSON with app and from; UNKNOWN_FILE No <from> in <app>, details { name } with the path; FILE_TOO_LARGE <from> is over the 2 GiB limit for one pull; I1's errors while unpacking are APP_FILES_FAILED; LEASE_FILES_FULL, INSUFFICIENT_DISK_SPACE, FILE_BUSY as a file's; 300 s as I7 src/core/app-files.ts, both drivers, src/lease-files/, src/http/ #2007 —
I10 simlock files pull <path> --app <id> [--name <name>] [--lease <id>] stores under --name, else the path's last part; waits 360 s for the answer; prints { lease, name, size, kind } exit 2 <last part> is not a file name a lease can hold; pass --name src/cli/commands/files.ts #2007 —
I11 LeaseFilesDeps additions archive: TreeArchive (#2004); LeaseFiles.handle and its gateway and HTTP twins take the action "file" | "folder" | "push" | "pull" beside the name — src/lease-files/types.ts, src/http/app-types.ts, src/daemon/worker-composition.ts #2004 #2005, #2006, #2007
I12 LeaseFilesDeps.appFiles supports(grant), write(grant, …, signal), and #2007's read, by the worker's composition over the catalog with the lease's device an AppFilesError becomes a LeaseFilesError of its code; any other error of the driver (a step's timeout, an emulator that is not running, a closed phone gate, an errno) becomes APP_FILES_FAILED with its message; a LeaseFilesError passes src/lease-files/types.ts, src/daemon/worker-composition.ts #2006 #2007
I13 HttpStreamRequest method takes POST; optional contentType, sent as the header — src/ports/http-stream.ts and its fake #2006 #2007
I14 simlock files get <name> asks the file route first; on NOT_A_FILE refuses a target that exists, then asks I4 and unpacks with I1 (links: "skip", strip: 0) into S3 exit 2 <target> exists; name a folder that does not exist with -o; a TreeEntryError or TreeFormatError is REMOTE_UNREACHABLE; an errno of this machine's disk stays itself src/cli/commands/files.ts #2005 —

Existing code

Commit d95c152.

Searches: rg -l "lease-files|leaseFiles|LeaseFiles" src (non-test, 8 files outside the module); rg "1636|folder cannot be uploaded" src website (6 hits); rg -l DeviceTcp src (23 files, the capability appFiles is modelled on); rg runAdbOn src (2 hits); rg LEASE_FILE_NAME_PATTERN src (6 hits).

Id Code (path:line) Today With this feature Handled by
X1 src/lease-files/store.ts:174 #names keeps regular files only; list, lookup, remove and the spelling check use it Folders of a valid name count too; openFile answers NOT_A_FILE for one from #2005, UNKNOWN_FILE before B1, B3, B8
X2 src/lease-files/store.ts:190 put and #receive hold the name's writer slot, the disk and size checks and the rename A folder goes through the same slot, checks and running-upload count B1, B2
X3 src/lease-files/store.ts:91 end aborts running uploads and waits for everything in flight It aborts a folder put, push and pull too; what it then waits for is an unpack that stops at its next entry, or the Android clean-up of at most 30 s B2, B11, B17
X4 src/lease-files/store.ts:123 sweep removes each .upload- entry with rm Also as a folder: rm is recursive in NodeFilesystem S2
X5 src/lease-files/relay-target.ts:6 A path with one segment after the lease id at most; anything else is BAD_REQUEST One of three words may follow the name B6, B10, B15, B21
X6 src/daemon/gateway-lease-files.ts:56 Builds the worker's path from the name, and bounds an upload by silence when it is a PUT Adds the action to the path; the folder PUT is an upload as a file's is B6
X7 src/daemon/callers-lease-id.ts:4 Puts the caller's lease id back in UNKNOWN_LEASE and LEASE_FILES_FULL No new code names a lease B6, B15
X8 src/cli/commands/files.ts:194 Refuses a folder, naming this issue Sends it B4
X9 src/cli/commands/passthrough.ts:102 A notice of its own for a folder The file's notice B5
X10 src/drivers/android/passthrough-rules.ts:335 (and 288), src/drivers/android/physical-handler.ts:143, src/drivers/android/index.ts:259 runAdbOn and runAdb run one adb command on a device, through the emulator's server or the phone's gate, to its end or a timeout They also take an optional signal, passed to ProcessRunner.run B13, B19
X11 src/daemon/dispatcher-exec.ts:184 #openStdinFile passes a LeaseFilesError of openFile on with its code Unchanged; NOT_A_FILE goes the same way B8
X12 src/lease-files/handler.ts:21 Answers a LeaseFilesError with its row of ERROR_TABLE and rethrows anything else Every action goes through it; I1's errors reach it only as LeaseFilesError B2, B11, B17
X13 src/core/driver.ts:408, driver-catalog.ts:137 deviceTcp is an optional driver member the catalog asks appFiles is another B11, B12, B13
X14 src/daemon/worker-composition.ts:354 Builds the lease files with the filesystem and the grant lookup Passes the archive and the driver's app files too I11, I12
X15 src/modules/host.ts:116 files is a core lease sub-route a module cannot take Unchanged: every new route is under it I3
X16 src/ports/filesystem.ts:503 MemoryFilesystem reads a relative link target as absolute and has no other kind I8 B1, B2, B4, B8

Tasks

flowchart LR
  A[#2004 put a folder] --> B[#2005 get it back]
  B --> C[#2006 push into an app]
  C --> D[#2007 pull out of an app]
Loading

Completion conditions:

Open work in the same area:

Written by an agent.

Sub-issues

Sub-issues

0 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    feature:spec
    on Nov 17, 2026
  2. changed the title [-]Upload a build once and install it on many leases, and put files into an app's container[/-] [+]Upload a folder or a build once for many leases, and put files into an app's container[/+] on Nov 17, 2026
  3. changed the title [-]Upload a folder or a build once for many leases, and put files into an app's container[/-] [+]Put folders into a lease's folder, and copy files into and out of an app's container[/+] on Nov 30, 2026
  4. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Design posted: the whole feature. The shared upload moved to #1998.

    Written by an agent.

  5. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Approve?

    #1636 Put folders into a lease's folder, and copy files into and out of an app's container: #1636
    ADR 0100 (PR #1999): a folder travels as one tar and is a folder at both ends; a copy into or out of an app's container moves one archive, with adb push and adb pull on Android and on the worker's disk for a simulator. Nothing on the device changes but the files.

    • Decided with the maintainer in the session of 2026-11-30: the shared upload is its own feature, Upload a build once and install it on many leases #1998.
    • Decided with the maintainer in the session of 2026-11-30: a folder is packed when sent and unpacked on the worker, and comes back the same way.
    • Decided with the maintainer in the session of 2026-11-30: Simlock writes into the container itself, with push and pull, on everything but real iPhones and iPads.
    • Decided with the maintainer in the session of 2026-11-30: no file goes through adb shell. A push sends one archive with adb push and the device unarchives it; a pull archives on the device and fetches it with adb pull. Measured with a debuggable app on the Android 15 default and the Android 16 Play emulator images: every byte the same, links and empty folders kept. adb push of the folder itself drops empty folders and fails on a link.
    • Decided in the session: the worker archives the folder again for a push, because the lease's folder holds it unarchived (simctl install needs that) and a command may have changed it since.
    • Decided in the session: copies on one Android device run one after another in one temporary folder of a fixed name, because the next copy then removes what a killed daemon left.
    • Decided in the session: tar, not zip, because a tar can be unpacked as it arrives and a zip's index is at its end.
    • Decided in the session: tar-stream 3.1.7 is added as a runtime dependency (its dependencies are b4a, fast-fifo and streamx, 396 KB installed) and its pack and extract are used (they read the long names of macOS's and Android's tar); Simlock writes each entry itself, because three system tar programs answer an unsafe entry in three ways. It is loaded on first use.
    • Decided in the session: the routes hang under /files/{name}/, because a new lease route name would also have to be refused as a module's name.
    • Decided in the session: push of a folder copies what is in it, and of a file the file under its name, because a user names the target folder and fixtures belong in it directly.
    • Decided in the session: pull lands in the lease's folder and get fetches it, because one transfer path then serves both.
    • Decided in the session: push and pull end after 300 s, because a gateway's relay waits 330 s for an answer; the CLI waits 360 s.
    • Decided in the session: files are written with mode 755 when the sender's entry was executable and 644 otherwise, folders 755, under the lease folder's 700, because adb push copies the mode to the device.
    • Decided in the session: an entry Simlock does not carry (a link that leads out, a \ in a name, a socket) fails a put and is left out of a get, a push and a pull, because the sender can fix its own folder and a reader cannot fix what a command or an app wrote.
    • Decided in the session: 2 GiB bounds a whole put folder and a whole pull, because both are one stream, as a file is.
    • Decided in the session: on Windows folders work without links and executable bits, because Windows has no such bit and lets only administrators create links.
    • Decided in the session: a push or pull whose caller goes away runs to its end, because the bytes are already on the worker and 300 s bound it.
    Task What it delivers Rows Depends on
    T1 simlock files put, list and rm take folders, so a simulator .app installs B1–B7, S1, S2, I1–I3, I5, I8, I11 —
    T2 simlock files get brings a folder back B8–B10, S3, I4, I14 T1
    T3 simlock files push copies into an app's container B11–B16, S4, I6, I7, I12, I13 T2
    T4 simlock files pull copies out of it B17–B22, I9, I10 T3

    Not tried: a real Android phone, Android 14 or older, a Windows worker.

    Check: ready

    Written by an agent.

  6. added a commit that references this issue on Nov 30, 2026
  7. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Spec updated: the Tasks section, the task numbers in the rows, and one decision (file calls do not count as use for #1899).

    Written by an agent.

  8. added
    feature:planned
    and removed
    feature:spec
    on Nov 30, 2026
  9. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Planned.

    Task What it delivers Depends on
    #2004 simlock files put, list and rm take folders, so a simulator .app installs #1154
    #2005 simlock files get brings a folder back #2004, #1155
    #2006 simlock files push copies into an app's container #2004, #2005
    #2007 simlock files pull copies out of it #2005, #2006

    chain 4 of 4 tasks

    Decided since the design was settled:

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions