From e756830696e0cfdc8139211243e1ef30adeb0a12 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 6 Jun 2008 10:17:58 +0200 Subject: [PATCH] Use open and fail if the file already exists. --- src/csync_propagate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/csync_propagate.c b/src/csync_propagate.c index 9381124fa5..6de1b41757 100644 --- a/src/csync_propagate.c +++ b/src/csync_propagate.c @@ -123,8 +123,7 @@ static int _csync_push_file(CSYNC *ctx, csync_file_stat_t *st) { /* Open the destination file */ ctx->replica = drep; - dfp = csync_vio_creat(ctx, turi, 0644); - while (dfp == NULL) { + while ((dfp = csync_vio_open(ctx, turi, O_CREAT|O_EXCL|O_WRONLY, st->mode)) == NULL) { switch (errno) { case ENOENT: break; @@ -150,7 +149,6 @@ static int _csync_push_file(CSYNC *ctx, csync_file_stat_t *st) { if (csync_vio_mkdirs(ctx, tdir, 0755) < 0) { CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "dir: %s, command: mkdirs, error: %s", tdir, strerror(errno)); } - dfp = csync_vio_creat(ctx, turi, st->mode); } /* copy file */