summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 49a0f24)
raw | patch | inline | side by side (parent: 49a0f24)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 30 Sep 2005 07:07:39 +0000 (00:07 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 2 Oct 2005 06:17:14 +0000 (23:17 -0700) |
Add the sanity checks discussed on the list with Nick Hengeveld in
<20050927000931.GA15615@reactrix.com>.
* unlink of previous and rename from temp to previous can fail for
reasons other than benign ones (missing previous and missing temp).
Report these failures when we encounter them, to make diagnosing
problems easier.
* when rewinding the partially written result, make sure to
truncate the file.
Also verify the pack after downloading by calling
verify_packfile().
Signed-off-by: Junio C Hamano <junkio@cox.net>
<20050927000931.GA15615@reactrix.com>.
* unlink of previous and rename from temp to previous can fail for
reasons other than benign ones (missing previous and missing temp).
Report these failures when we encounter them, to make diagnosing
problems easier.
* when rewinding the partially written result, make sure to
truncate the file.
Also verify the pack after downloading by calling
verify_packfile().
Signed-off-by: Junio C Hamano <junkio@cox.net>
http-fetch.c | patch | blob | history |
diff --git a/http-fetch.c b/http-fetch.c
index 778d508243e78bc5c3dce2d71ab6c225c6a3159f..e8ac9959ff712f3d482789ac00e6181fd8461931 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
#include "cache.h"
#include "commit.h"
-
+#include "pack.h"
#include "fetch.h"
#include <curl/curl.h>
lst = &((*lst)->next);
*lst = (*lst)->next;
+ if (verify_pack(target, 0))
+ return -1;
install_packed_git(target);
return 0;
snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
snprintf(prevfile, sizeof(prevfile), "%s.prev", filename);
- unlink(prevfile);
- rename(tmpfile, prevfile);
- unlink(tmpfile);
+
+ if (unlink(prevfile) && (errno != ENOENT))
+ return error("Failed to unlink %s (%s)",
+ prevfile, strerror(errno));
+ if (rename(tmpfile, prevfile) && (errno != ENOENT))
+ return error("Failed to rename %s to %s (%s)",
+ tmpfile, prevfile, strerror(errno));
local = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0666);
if (prev_posn>0) {
prev_posn = 0;
lseek(local, SEEK_SET, 0);
+ ftruncate(local, 0);
}
}