Document REST POST /restful/rhizome/insert

Adds definitions for Rhizome concepts such as Bundle ID, Bundle Secret,
payload, etc. and a detailed step-by-step definition of the insertion
logic.
This commit is contained in:
Andrew Bettison 2015-12-01 00:36:18 +10:30
parent 3f8f0f6fc7
commit bd45186a6a
3 changed files with 728 additions and 119 deletions

File diff suppressed because it is too large Load Diff

View File

@ -478,6 +478,7 @@ static int insert_mime_part_header(struct http_request *hr, const struct mime_pa
// Reject a request if this parameter comes after the manifest part. // Reject a request if this parameter comes after the manifest part.
if (r->u.insert.received_manifest) if (r->u.insert.received_manifest)
return http_response_form_part(r, 400, "Spurious", PART_AUTHOR, NULL, 0); return http_response_form_part(r, 400, "Spurious", PART_AUTHOR, NULL, 0);
// TODO enforce correct content type
r->u.insert.current_part = PART_AUTHOR; r->u.insert.current_part = PART_AUTHOR;
assert(r->u.insert.author_hex_len == 0); assert(r->u.insert.author_hex_len == 0);
} }
@ -487,6 +488,7 @@ static int insert_mime_part_header(struct http_request *hr, const struct mime_pa
// Reject a request if this parameter comes after the manifest part. // Reject a request if this parameter comes after the manifest part.
if (r->u.insert.received_manifest) if (r->u.insert.received_manifest)
return http_response_form_part(r, 400, "Spurious", PART_SECRET, NULL, 0); return http_response_form_part(r, 400, "Spurious", PART_SECRET, NULL, 0);
// TODO enforce correct content type
r->u.insert.current_part = PART_SECRET; r->u.insert.current_part = PART_SECRET;
assert(r->u.insert.secret_text_len == 0); assert(r->u.insert.secret_text_len == 0);
} }
@ -496,6 +498,7 @@ static int insert_mime_part_header(struct http_request *hr, const struct mime_pa
// Reject a request if this parameter comes after the manifest part. // Reject a request if this parameter comes after the manifest part.
if (r->u.insert.received_manifest) if (r->u.insert.received_manifest)
return http_response_form_part(r, 400, "Spurious", PART_BUNDLEID, NULL, 0); return http_response_form_part(r, 400, "Spurious", PART_BUNDLEID, NULL, 0);
// TODO enforce correct content type
r->u.insert.current_part = PART_BUNDLEID; r->u.insert.current_part = PART_BUNDLEID;
assert(r->u.insert.bid_text_len == 0); assert(r->u.insert.bid_text_len == 0);
} }
@ -521,6 +524,7 @@ static int insert_mime_part_header(struct http_request *hr, const struct mime_pa
if (!r->u.insert.received_manifest) if (!r->u.insert.received_manifest)
return http_response_form_part(r, 400, "Missing", PART_MANIFEST, NULL, 0); return http_response_form_part(r, 400, "Missing", PART_MANIFEST, NULL, 0);
assert(r->manifest != NULL); assert(r->manifest != NULL);
// TODO enforce correct content type
r->u.insert.current_part = PART_PAYLOAD; r->u.insert.current_part = PART_PAYLOAD;
// If the manifest does not contain a 'name' field, then assign it from the payload filename. // If the manifest does not contain a 'name' field, then assign it from the payload filename.
if ( strcasecmp(RHIZOME_SERVICE_FILE, r->manifest->service) == 0 if ( strcasecmp(RHIZOME_SERVICE_FILE, r->manifest->service) == 0

View File

@ -1637,8 +1637,10 @@ enum rhizome_payload_status rhizome_finish_store(struct rhizome_write *write, rh
DEBUGF(rhizome, "m->filesize=%"PRIu64", write->file_length=%"PRIu64, m->filesize, write->file_length); DEBUGF(rhizome, "m->filesize=%"PRIu64", write->file_length=%"PRIu64, m->filesize, write->file_length);
return RHIZOME_PAYLOAD_STATUS_WRONG_SIZE; return RHIZOME_PAYLOAD_STATUS_WRONG_SIZE;
} }
if (m->is_journal) if (m->is_journal) {
rhizome_manifest_set_version(m, m->filesize); // TODO ensure new version is greater than previous version
rhizome_manifest_set_version(m, m->tail + m->filesize);
}
if (m->filesize) { if (m->filesize) {
if (m->is_journal || !m->has_filehash) if (m->is_journal || !m->has_filehash)
rhizome_manifest_set_filehash(m, &write->id); rhizome_manifest_set_filehash(m, &write->id);