Changeset: fbe45f8c7f4b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fbe45f8c7f4b
Modified Files:
        gdk/gdk_posix.c
Branch: Jan2014
Log Message:

Only delete destination in rename if source exists.


diffs (33 lines):

diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -994,17 +994,25 @@ win_unlink(const char *pathname)
 
 #undef rename
 int
-win_rename(const char *old, const char *new)
+win_rename(const char *old, const char *dst)
 {
-       int ret = rename(old, new);
+       int ret;
+
+       ret = rename(old, dst);
+       if (ret == 0 || (ret < 0 && errno == ENOENT))
+               return ret;
+       if (ret < 0 && errno == EEXIST) {
+               (void) win_unlink(dst);
+               ret = rename(old, dst);
+       }
 
        if (ret < 0 && errno != ENOENT) {
                /* it could be the <expletive deleted> indexing
                 * service which prevents us from doing what we have a
                 * right to do, so try again (once) */
-               IODEBUG THRprintf(GDKstdout, "#retry rename %s %s\n", old, new);
+               IODEBUG THRprintf(GDKstdout, "#retry rename %s %s\n", old, dst);
                MT_sleep_ms(100);       /* wait a little */
-               ret = rename(old, new);
+               ret = rename(old, dst);
        }
        return ret;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to