failed();
}
if (st.st_size > 0) {
- if (move_file(tmp_stderr, cached_stderr, compress) != 0) {
+ if (move_uncompressed_file(tmp_stderr, cached_stderr,
+ compress) != 0) {
cc_log("Failed to move %s to %s",
tmp_stderr, cached_stderr);
stats_update(STATS_ERROR);
} else {
unlink(tmp_stderr);
}
- if (move_file(tmp_obj, cached_obj, compress) != 0) {
+ if (move_uncompressed_file(tmp_obj, cached_obj, compress) != 0) {
cc_log("Failed to move %s to %s", tmp_obj, cached_obj);
stats_update(STATS_ERROR);
failed();
void copy_fd(int fd_in, int fd_out);
int copy_file(const char *src, const char *dest, int compress_dest);
int move_file(const char *src, const char *dest, int compress_dest);
+int move_uncompressed_file(const char *src, const char *dest,
+ int compress_dest);
int test_if_compressed(const char *filename);
int create_dir(const char *dir);
return ret;
}
+/*
+ * Like move_file(), but assumes that src is uncompressed and that src and dest
+ * are on the same file system.
+ */
+int
+move_uncompressed_file(const char *src, const char *dest, int compress_dest)
+{
+ if (compress_dest) {
+ return move_file(src, dest, compress_dest);
+ } else {
+ return rename(src, dest);
+ }
+}
+
/* test if a file is zlib compressed */
int test_if_compressed(const char *filename)
{