make it more obvious that temporary files are temporary files
When some operations are interrupted (or "die()'d" or crashed) then the partial object/pack/index file may remain around. Make it more obvious in their name that those files are temporary stuff and can be cleaned up if no operation is in progress. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Nicolas Pitre committed
Mar 24, 2007 at 11:58 UTC
0e55181f29ee6599ab6888ac54d186c83d355a70
3 files changed
+6
-6
fast-import.c
+2
-2
@@ -630,7 +630,7 @@ static void start_packfile(void)
630
int pack_fd;
631
632
snprintf(tmpfile, sizeof(tmpfile),
633
- "%s/pack_XXXXXX", get_object_directory());
633
+ "%s/tmp_pack_XXXXXX", get_object_directory());
634
pack_fd = mkstemp(tmpfile);
635
if (pack_fd < 0)
636
die("Can't create %s: %s", tmpfile, strerror(errno));
@@ -730,7 +730,7 @@ static char *create_index(void)
730
}
731
732
snprintf(tmpfile, sizeof(tmpfile),
733
- "%s/index_XXXXXX", get_object_directory());
733
+ "%s/tmp_idx_XXXXXX", get_object_directory());
734
idx_fd = mkstemp(tmpfile);
735
if (idx_fd < 0)
736
die("Can't create %s: %s", tmpfile, strerror(errno));
index-pack.c
+2
-2
@@ -139,7 +139,7 @@ static const char *open_pack_file(const char *pack_name)
139
if (!pack_name) {
140
static char tmpfile[PATH_MAX];
141
snprintf(tmpfile, sizeof(tmpfile),
142
- "%s/pack_XXXXXX", get_object_directory());
142
+ "%s/tmp_pack_XXXXXX", get_object_directory());
143
output_fd = mkstemp(tmpfile);
144
pack_name = xstrdup(tmpfile);
145
} else
@@ -690,7 +690,7 @@ static const char *write_index_file(const char *index_name, unsigned char *sha1)
690
if (!index_name) {
691
static char tmpfile[PATH_MAX];
692
snprintf(tmpfile, sizeof(tmpfile),
693
- "%s/index_XXXXXX", get_object_directory());
693
+ "%s/tmp_idx_XXXXXX", get_object_directory());
694
fd = mkstemp(tmpfile);
695
index_name = xstrdup(tmpfile);
696
} else {
sha1_file.c
+2
-2
@@ -1979,7 +1979,7 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
1979
return error("sha1 file %s: %s\n", filename, strerror(errno));
1980
}
1981
1982
- snprintf(tmpfile, sizeof(tmpfile), "%s/obj_XXXXXX", get_object_directory());
1982
+ snprintf(tmpfile, sizeof(tmpfile), "%s/tmp_obj_XXXXXX", get_object_directory());
1983
1984
fd = mkstemp(tmpfile);
1985
if (fd < 0) {
@@ -2105,7 +2105,7 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,
2105
int ret;
2106
SHA_CTX c;
2107
2108
- snprintf(tmpfile, sizeof(tmpfile), "%s/obj_XXXXXX", get_object_directory());
2108
+ snprintf(tmpfile, sizeof(tmpfile), "%s/tmp_obj_XXXXXX", get_object_directory());
2109
2110
local = mkstemp(tmpfile);
2111
if (local < 0) {