pub struct PushRequest {
pub project_key: String,
pub file_path: String,
pub content: Option<String>,
pub source_env: String,
pub deleted: bool,
pub base_sha256: Option<String>,
}Expand description
Body of POST /sync: one memory file, or one delete.
content is an Option, not a String, and that is load-bearing:
it has to distinguish “this file is empty” (Some(""), serialized as
"content":"") from “this is a delete, there is no content” (None,
omitted entirely).
Skipping on emptiness instead — the obvious-looking
skip_serializing_if = "String::is_empty" — omits the field for an
empty file too, and the deployed Node server rejects that push with a
400, since typeof undefined !== "string". Both the Go and the first
Rust implementation had exactly that bug, and neither test suite caught
it: every test that exercised an empty file used a stand-in server that
accepted anything. It surfaced only when the compatibility script ran a
real empty-file push against the real Node server.
Fields§
§project_key: StringWhich project this file belongs to. See recall_hooks::project.
file_path: StringThe file’s path relative to the project’s memory directory.
content: Option<String>The file’s exact bytes, or None to mean “this is a delete”.
source_env: StringA label for the machine that sent this, for display only.
deleted: boolWhether this push is a delete rather than a write.
base_sha256: Option<String>content_sha256 of the version this edit
started from: the content this client last pulled or pushed for the
file. None when the client does not know — an older client, or a
file it has never synced.
It is what lets the server tell the next edit from a concurrent one.
Without it every push that differs from what is stored went through
the semantic merge, which keeps “every distinct fact from both
versions” — so a line deleted on purpose was a fact from the stored
side and came back, and so did a resolved CONFLICT marker. When the
stored version is the one named here, nothing happened in between
and the push simply replaces it.
Implementations§
Source§impl PushRequest
impl PushRequest
Sourcepub fn validate(&self) -> Result<(), ValidationError>
pub fn validate(&self) -> Result<(), ValidationError>
Checks a push is well-formed, applying the same rules on both sides of the wire: the client refuses to send what the server would refuse to accept, so the user sees the real reason rather than a 400.