diff options
author | owsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2008-12-17 23:07:11 +0000 |
---|---|---|
committer | owsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2008-12-17 23:07:11 +0000 |
commit | 699dff9b9a8053966eb79c6e7d7fec175ad4e4d7 (patch) | |
tree | 60961c4c02b5d1bf2493ab4f807e0fb2722f942a /rdiff-backup | |
parent | bd7c86de2d5ed0226c5427537effdc8d6c4a78a3 (diff) | |
download | rdiff-backup-699dff9b9a8053966eb79c6e7d7fec175ad4e4d7.tar.gz |
Fix for crash when deleting read-only files on Windows. (Patch from Josh Nisly)
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@966 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup')
-rw-r--r-- | rdiff-backup/CHANGELOG | 2 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/rpath.py | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index f2a47da..e600968 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -1,6 +1,8 @@ New in v1.2.3 (????/??/??) --------------------------- +Fix for crash when deleting read-only files on Windows. (Patch from Josh Nisly) + Fix for Python 2.2 in win_acls.py (Closes Savannah bug #24922). Throttle verbosity of listattr() warning messages from 3 to 4. (Andrew Ferguson) diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py index e5e19fa..08b63b7 100644 --- a/rdiff-backup/rdiff_backup/rpath.py +++ b/rdiff-backup/rdiff_backup/rpath.py @@ -261,6 +261,7 @@ def rename(rp_source, rp_dest): 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) @@ -1055,7 +1056,17 @@ class RPath(RORPath): 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) + else: + raise + self.setdata() def contains_files(self): |