Improve sha1 object file writing.
Make it much safer: we write to a temporary file, and then link that temporary file to the final destination. This avoids all the nasty races if several people write the same object at the same time. It should also result in nicer on-disk layout, since it means that objects all get created in the same subdirectory. That makes a lot of block allocation algorithms happier, since the objects will now be allocated from the same zone.
This commit is contained in:
3
cache.h
3
cache.h
@ -128,9 +128,6 @@ extern int index_fd(unsigned char *sha1, int fd, struct stat *st);
|
||||
/* Return a statically allocated filename matching the sha1 signature */
|
||||
extern char *sha1_file_name(const unsigned char *sha1);
|
||||
|
||||
/* Write a memory buffer out to the sha file */
|
||||
extern int write_sha1_buffer(const unsigned char *sha1, void *buf, unsigned int size);
|
||||
|
||||
/* Read and unpack a sha1 file into memory, write memory to a sha1 file */
|
||||
extern void * map_sha1_file(const unsigned char *sha1, unsigned long *size);
|
||||
extern void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, unsigned long *size);
|
||||
|
||||
Reference in New Issue
Block a user