Commit 9664d99e authored by owsla's avatar owsla

Do not use inode numbers on Windows and gracefully handle attempts to

rename over existing files on Windows. (Patch from Josh Nisly)


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@886 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 6d2baeb3
New in v1.1.16 (????/??/??) New in v1.1.16 (????/??/??)
--------------------------- ---------------------------
Do not use inode numbers on Windows and gracefully handle attempts to
rename over existing files on Windows. (Patch from Josh Nisly)
Finally fix 'No such file or directory' bug when attempting to regress after Finally fix 'No such file or directory' bug when attempting to regress after
a failed backup. (Patch from Josh Nisly) a failed backup. (Patch from Josh Nisly)
......
...@@ -66,6 +66,8 @@ ...@@ -66,6 +66,8 @@
/* The following section is by Jeffrey A. Marshall and compensates for /* The following section is by Jeffrey A. Marshall and compensates for
* a bug in Mac OS X's S_ISFIFO and S_ISSOCK macros. * a bug in Mac OS X's S_ISFIFO and S_ISSOCK macros.
* Note: Starting in Mac OS X 10.3, the buggy macros were changed to be
* the same as the ones below.
*/ */
#ifdef __APPLE__ #ifdef __APPLE__
/* S_ISFIFO/S_ISSOCK macros from <sys/stat.h> on mac osx are bogus */ /* S_ISFIFO/S_ISSOCK macros from <sys/stat.h> on mac osx are bogus */
...@@ -116,13 +118,18 @@ static PyObject *c_make_file_dict(self, args) ...@@ -116,13 +118,18 @@ static PyObject *c_make_file_dict(self, args)
return NULL; return NULL;
} }
} }
#if defined(MS_WINDOWS)
size = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_size);
inode = PyLong_FromLongLong((PY_LONG_LONG)-1);
#else
#ifdef HAVE_LARGEFILE_SUPPORT #ifdef HAVE_LARGEFILE_SUPPORT
size = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_size); size = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_size);
inode = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_ino); inode = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_ino);
#else #else
size = PyInt_FromLong(sbuf.st_size); size = PyInt_FromLong(sbuf.st_size);
inode = PyInt_FromLong((long)sbuf.st_ino); inode = PyInt_FromLong((long)sbuf.st_ino);
#endif #endif /* HAVE_LARGEFILE_SUPPORT */
#endif /* defined(MS_WINDOWS) */
mode = (long)sbuf.st_mode; mode = (long)sbuf.st_mode;
perms = mode & 07777; perms = mode & 07777;
#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
......
...@@ -244,12 +244,22 @@ def rename(rp_source, rp_dest): ...@@ -244,12 +244,22 @@ def rename(rp_source, rp_dest):
log.Log(lambda: "Renaming %s to %s" % (rp_source.path, rp_dest.path), 7) log.Log(lambda: "Renaming %s to %s" % (rp_source.path, rp_dest.path), 7)
if not rp_source.lstat(): rp_dest.delete() if not rp_source.lstat(): rp_dest.delete()
else: else:
if rp_dest.lstat() and rp_source.getinode() == rp_dest.getinode(): if rp_dest.lstat() and rp_source.getinode() == rp_dest.getinode() and \
rp_source.getinode() != -1:
log.Log("Warning: Attempt to rename over same inode: %s to %s" log.Log("Warning: Attempt to rename over same inode: %s to %s"
% (rp_source.path, rp_dest.path), 2) % (rp_source.path, rp_dest.path), 2)
# You can't rename one hard linked file over another # You can't rename one hard linked file over another
rp_source.delete() rp_source.delete()
else: rp_source.conn.os.rename(rp_source.path, rp_dest.path) else:
try:
rp_source.conn.os.rename(rp_source.path, rp_dest.path)
except OSError, error:
if error.errno != errno.EEXIST: raise
# On Windows, files can't be renamed on top of an existing file
rp_source.conn.os.unlink(rp_dest.path)
rp_source.conn.os.rename(rp_source.path, rp_dest.path)
rp_dest.data = rp_source.data rp_dest.data = rp_source.data
rp_source.data = {'type': None} rp_source.data = {'type': None}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment