
Fetch One File From a Mergin Project Without Cloning It
Source:R/rfp_mergin.R
rfp_mergin_file_get.RdDownload a single file straight from the server. newgraph/hornby_2026 is
327 MB and its .qgs is 2.2 MB, so reading a project file out of a clone
costs about 150x what the task needs.
Arguments
- project
Character.
namespace/project.- file
Character. Path within the project, e.g.
"hornby_2026.qgs".- path_out
Character. Local destination file (not a directory). Parent directories are created.
- version
Character.
"vN", orNULL(default) for HEAD.- overwrite
Logical. Replace
path_outif it exists. DefaultFALSE- a fetched.qgslanding on top of a live project file is the expensive mistake this guards.
What is verified
The file's checksum, against what the server reported for that version - not just that something arrived. The download reads in chunks and treats a short read as end-of-file, so a truncated transfer produces a plausible-looking file rather than an error. Checking bytes on disk is the pattern this subsystem already uses in place of trusting an exit code (#60); the checksum is that, one step stronger, and it is free because the file listing already carries it.
One exception (#408). A GeoPackage whose change at a version was a geodiff
diff is stored as diffs and rebuilt by the server on request, so its bytes
cannot match the checksum the pushing client computed. For a .gpkg or
.sqlite that fails its checksum, the last change at or before version is
looked up: if it was a diff, the file is accepted when PRAGMA integrity_check is ok and every table the change touched holds the
previous version's rows plus its inserts minus its deletes, and a message
says so. That costs one more download, of the previous version. A change
uploaded whole, and any other file type, must match by checksum.