rdiff-backup-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [rdiff-backup-users] bug/crash on read-only file in incremental back


From: Josh Nisly
Subject: Re: [rdiff-backup-users] bug/crash on read-only file in incremental backup
Date: Fri, 14 Nov 2008 17:33:26 -0600
User-agent: Thunderbird 2.0.0.17 (X11/20080925)

Attached is a patch that fixes the problem for me. I get a slightly different traceback than was reported by others, but this is the correct solution. The problem is that Windows does not allow deletion of read-only files. This patch simply removes the readonly flag before removing the file. (This is the same behavior as Windows Explorer.)

Thanks,
JoshN

Andrew Ferguson wrote:
Josh --

You may or may not find this patch helpful when you are working on the read-only files. This is my patch to support filesystem flags like 'immutable' or 'secure delete' ... obviously when flags like 'immutable' are set, it becomes important to unset it as necessary. Follow the placement of the "make_fsflags_mutable" calls.

I never incorporated this patch into CVS because 1) it needed to switch to having tests in fs_abilities and 2) I needed to figure how to detect support for chflags(2) -- I think Python 2.6 added chflags() support, but I'll have to double-check.

I suppose another piece of advice would be to watch for the places where chmod() is called directly in the current rdiff-backup -- things like chmod(0700 | file.perms()) are a good bet for places where we need to adjust the permissions to make the backup work.


Andrew







On Nov 14, 2008, at 11:26 AM, Josh Nisly wrote:

I was planning on fixing this. Are you already working on it? If not, I'll try to send a patch in the next day or two.

JoshN

Andrew Ferguson wrote:
On Nov 14, 2008, at 8:18 AM, Philip Warner wrote:
Hi,

On windows, I get the following crash when doing an incremental on a
file that is read-only, but which has been updated.

Googling produced the only other reference:

http://lists.gnu.org/archive/html/rdiff-backup-users/2008-11/msg00011.html

which went unanswered.

Any suggestions?


Philip --

Thank you for bringing this issue up again. Somehow, I missed the earlier post.

I'll work on fixing this bug for the next release. On Unix, I believe rdiff-backup generally handles this situation correctly. From your traceback, it is clear that Windows returns Windows-specific error codes in this instance, which rdiff-backup was unprepared to handle.


Andrew


_______________________________________________
rdiff-backup-users mailing list at address@hidden
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki




--- rdiff_backup/rpath.py       12 Oct 2008 02:21:30 -0000      1.131
+++ rdiff_backup/rpath.py       14 Nov 2008 23:25:55 -0000
@@ -253,11 +253,13 @@
                        rp_source.delete()
                else:
                        try:
-                           rp_source.conn.os.rename(rp_source.path, 
rp_dest.path)
+                               rp_source.conn.os.rename(rp_source.path, 
rp_dest.path)
                        except OSError, error:
-                               if error.errno != errno.EEXIST: raise
+                               if error.errno != errno.EEXIST and \
+                                       error.errno != errno.EPERM: raise
 
                                # On Windows, files can't be renamed on top of 
an existing file
+                               rp_source.conn.os.chmod(rp_dest.path, 0700)
                                rp_source.conn.os.unlink(rp_dest.path)
                                rp_source.conn.os.rename(rp_source.path, 
rp_dest.path)
                            
@@ -1052,7 +1054,15 @@
                        except os.error:
                                if Globals.fsync_directories: self.fsync()
                                self.conn.shutil.rmtree(self.path)
-               else: self.conn.os.unlink(self.path)
+               else:
+                       try: self.conn.os.unlink(self.path)
+                       except OSError, error:
+                                       if error.errno == errno.EPERM:
+                                               # On Windows, read-only files 
cannot be deleted.
+                                               # Remove the read-only 
attribute and try again.
+                                               self.chmod(0700)
+                                               self.conn.os.unlink(self.path)
+
                self.setdata()
 
        def contains_files(self):

reply via email to

[Prev in Thread] Current Thread [Next in Thread]