diff options
author | nulltoken <emeric.fermas@gmail.com> | 2013-09-07 22:39:05 +0200 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2013-09-07 23:00:20 +0200 |
commit | 031f3f8028835c935d1e75ebd136aaaefffea821 (patch) | |
tree | f1464b2553df04c9860bfb9404c41a74b4509c0f /include/git2 | |
parent | ef6389ad504037e7a4311adbf14f1fa5a5aa4190 (diff) | |
download | libgit2-031f3f8028835c935d1e75ebd136aaaefffea821.tar.gz |
odb: Error when streaming in too [few|many] bytes
Diffstat (limited to 'include/git2')
-rw-r--r-- | include/git2/odb.h | 6 | ||||
-rw-r--r-- | include/git2/odb_backend.h | 13 |
2 files changed, 16 insertions, 3 deletions
diff --git a/include/git2/odb.h b/include/git2/odb.h index 3e93a932c..e50a2a1c1 100644 --- a/include/git2/odb.h +++ b/include/git2/odb.h @@ -238,6 +238,9 @@ GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, size_t s /** * Write to an odb stream * + * This method will fail as soon as the total number of + * received bytes exceeds the size declared with `git_odb_open_wstream()` + * * @param stream the stream * @param buffer the data to write * @param len the buffer's length @@ -251,6 +254,9 @@ GIT_EXTERN(int) git_odb_stream_write(git_odb_stream *stream, const char *buffer, * The object will take its final name and will be available to the * odb. * + * This method will fail if the total number of received bytes + * differs from the size declared with `git_odb_open_wstream()` + * * @param out pointer to store the resulting object's id * @param stream the stream * @return 0 on success; an error code otherwise diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h index bafeec047..e558bbb1c 100644 --- a/include/git2/odb_backend.h +++ b/include/git2/odb_backend.h @@ -78,6 +78,9 @@ struct git_odb_stream { unsigned int mode; void *hash_ctx; + size_t declared_size; + size_t received_bytes; + /** * Write at most `len` bytes into `buffer` and advance the * stream. @@ -93,9 +96,13 @@ struct git_odb_stream { * Store the contents of the stream as an object with the id * specified in `oid`. * - * This method will *not* be invoked by libgit2 if the object pointed at - * by `oid` already exists in any backend. Libgit2 will however take care - * of properly disposing the stream through a call to `free()`. + * This method will *not* be invoked by libgit2 when: + * - the object pointed at by `oid` already exists in any backend. + * - the total number of received bytes differs from the size declared + * with `git_odb_open_wstream()` + * + * Libgit2 will however take care of properly disposing the stream through + * a call to `free()`. */ int (*finalize_write)(git_odb_stream *stream, const git_oid *oid); |