fix: preserve documents on repeat create
This commit is contained in:
parent
f7f12480d0
commit
6fc1410e65
3 changed files with 25 additions and 4 deletions
|
|
@ -7754,6 +7754,11 @@ pub fn handle_request(
|
|||
ControlRequest::DocumentCreate { name } => {
|
||||
geth_document::validate_document_name(&name)
|
||||
.map_err(|_| NodeError::InvalidDocumentName(name.clone()))?;
|
||||
if let Some(existing) = store.get_document_resource_by_name(&name)? {
|
||||
return Ok(ControlResponse::DocumentCreated {
|
||||
document: document_resource_from_stored(&existing),
|
||||
});
|
||||
}
|
||||
let resource_id = format!("resource:document:{name}");
|
||||
let document_id = format!("document:{name}");
|
||||
let resource = StoredResource {
|
||||
|
|
|
|||
|
|
@ -3617,6 +3617,14 @@ fn kv_create_set_get_use_local_store() {
|
|||
other => panic!("unexpected response: {other:?}"),
|
||||
}
|
||||
|
||||
geth_node::handle_request(
|
||||
&node,
|
||||
geth_control::ControlRequest::KvCreate {
|
||||
name: "prefs".to_owned(),
|
||||
},
|
||||
)
|
||||
.expect("repeat kv create");
|
||||
|
||||
let response = geth_node::handle_request(
|
||||
&node,
|
||||
geth_control::ControlRequest::KvGet {
|
||||
|
|
@ -3772,6 +3780,14 @@ fn document_create_and_status_use_local_store() {
|
|||
other => panic!("unexpected response: {other:?}"),
|
||||
}
|
||||
|
||||
geth_node::handle_request(
|
||||
&node,
|
||||
geth_control::ControlRequest::DocumentCreate {
|
||||
name: "notes".to_owned(),
|
||||
},
|
||||
)
|
||||
.expect("repeat document create");
|
||||
|
||||
let reopened = geth_node::open_node(&paths).expect("reopen node");
|
||||
let response = geth_node::handle_request(
|
||||
&reopened,
|
||||
|
|
|
|||
|
|
@ -252,11 +252,11 @@ Goal: make `geth` ergonomic and stable as a base layer for custom automation.
|
|||
or stale.
|
||||
- `[x]` Wait commands support JSON output and timeout flags.
|
||||
|
||||
- `[ ]` Make common commands idempotent.
|
||||
- `[x]` Make common commands idempotent.
|
||||
Acceptance criteria:
|
||||
- `[ ]` Resource creation commands can be safely repeated where practical.
|
||||
- `[ ]` Grant creation supports deterministic caller-provided IDs.
|
||||
- `[ ]` Repeated sync and import commands report no-op state clearly.
|
||||
- `[x]` Resource creation commands can be safely repeated where practical.
|
||||
- `[x]` Grant creation supports deterministic caller-provided IDs.
|
||||
- `[x]` Repeated sync and import commands report no-op state clearly.
|
||||
|
||||
- `[x]` Publish automation examples.
|
||||
Acceptance criteria:
|
||||
|
|
|
|||
Loading…
Reference in a new issue