Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exists ¶
Exists returns whether an object for a given hash exists in an object path. The hash must be lower case. Returns false if objpath is empty.
func HashFromETag ¶
HashFromETag attempts to convert an ETag to a valid hash. Returns an empty string if the hash could not be converted.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes an object.
func NewWriter ¶
NewWriter returns a new Writer. If objpath is empty, then nil is returned. Otherwise, an ObjectWriter is returned, which will write to a temporary file. The opening of the file is deferred to the first call to Write.
func (*Writer) AsWriter ¶
AsWriter returns the ObjectWriter as an io.Writer, ensuring that a nil pointer results in a nil interface.
func (*Writer) Close ¶
Close finishes writing the file. A hash of the written content is computed, and always returned. The size of the content is also always returned.
If successfully written, the file is moved to the objpath directory with the hash as the file name. The file is located under a subdirectory that is named after the first two characters of the hash. This subdirectory will be created if it does not exist.
hash: d41d8cd98f00b204e9800998ecf8427e path: objects/d4/d41d8cd98f00b204e9800998ecf8427e
If an error occurs, the temporary file will persist. It can be removed with Remove().
func (*Writer) ExpectSize ¶
ExpectSize sets the expected size of the file, which will be checked when the file is closed.