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

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

[Rdiff-backup-commits] rdiff-backup CHANGELOG rdiff_backup/FilenameMap..


From: Andrew Ferguson
Subject: [Rdiff-backup-commits] rdiff-backup CHANGELOG rdiff_backup/FilenameMap...
Date: Thu, 13 Nov 2008 00:15:56 +0000

CVSROOT:        /sources/rdiff-backup
Module name:    rdiff-backup
Changes by:     Andrew Ferguson <owsla> 08/11/13 00:15:56

Modified files:
        .              : CHANGELOG 
        rdiff_backup   : FilenameMapping.py fs_abilities.py 

Log message:
        Escape trailing spaces and periods on systems which require it

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/rdiff-backup/CHANGELOG?cvsroot=rdiff-backup&r1=1.321&r2=1.322
http://cvs.savannah.gnu.org/viewcvs/rdiff-backup/rdiff_backup/FilenameMapping.py?cvsroot=rdiff-backup&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/rdiff-backup/rdiff_backup/fs_abilities.py?cvsroot=rdiff-backup&r1=1.55&r2=1.56

Patches:
Index: CHANGELOG
===================================================================
RCS file: /sources/rdiff-backup/rdiff-backup/CHANGELOG,v
retrieving revision 1.321
retrieving revision 1.322
diff -u -b -r1.321 -r1.322
--- CHANGELOG   12 Nov 2008 21:37:29 -0000      1.321
+++ CHANGELOG   13 Nov 2008 00:15:55 -0000      1.322
@@ -1,6 +1,9 @@
 New in v1.2.3 (????/??/??)
 ---------------------------
 
+Escape trailing spaces and periods on systems which require it, such as
+Windows and modern Linux with FAT32. (Andrew Ferguson)
+
 Print nicer error messages in rdiff-backup-statistics (without tracebacks).
 Closes Ubuntu bug #292586. (Andrew Ferguson)
 

Index: rdiff_backup/FilenameMapping.py
===================================================================
RCS file: /sources/rdiff-backup/rdiff-backup/rdiff_backup/FilenameMapping.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- rdiff_backup/FilenameMapping.py     5 Jan 2008 18:43:13 -0000       1.14
+++ rdiff_backup/FilenameMapping.py     13 Nov 2008 00:15:56 -0000      1.15
@@ -85,6 +85,19 @@
 
        """
        QuotedPath = chars_to_quote_regexp.sub(quote_single, path)
+       if not Globals.must_escape_dos_devices \
+                       and not Globals.must_escape_trailing_spaces:
+               return QuotedPath
+
+       if Globals.must_escape_dos_devices:
+               assert Globals.must_escape_trailing_spaces
+
+       # Escape a trailing space or period (invalid in names on FAT32 under 
DOS,
+       # Windows and modern Linux)
+       if len(QuotedPath) and (QuotedPath[-1] == ' ' or QuotedPath[-1] == '.'):
+               QuotedPath = QuotedPath[:-1] + \
+                               "%s%03d" % (quoting_char, ord(QuotedPath[-1]))
+
        if not Globals.must_escape_dos_devices:
                return QuotedPath
 

Index: rdiff_backup/fs_abilities.py
===================================================================
RCS file: /sources/rdiff-backup/rdiff-backup/rdiff_backup/fs_abilities.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- rdiff_backup/fs_abilities.py        12 Nov 2008 18:51:09 -0000      1.55
+++ rdiff_backup/fs_abilities.py        13 Nov 2008 00:15:56 -0000      1.56
@@ -50,6 +50,8 @@
        high_perms = None # True if suid etc perms are (read/write) supported
        escape_dos_devices = None # True if dos device files can't be created 
(e.g.,
                                                          # aux, con, com1, etc)
+       escape_trailing_spaces = None # True if files with trailing spaces or
+                                                                 # periods 
can't be created
        symlink_perms = None # True if symlink perms are affected by umask
 
        def __init__(self, name = None):
@@ -101,6 +103,8 @@
                                                  ('Windows access control 
lists', self.win_acls),
                                                  ('Case sensitivity', 
self.case_sensitive),
                                                  ('Escape DOS devices', 
self.escape_dos_devices),
+                                                 ('Escape trailing spaces',
+                                                  self.escape_trailing_spaces)
                                                  ('Mac OS X style resource 
forks',
                                                   self.resource_forks),
                                                  ('Mac OS X Finder 
information', self.carbonfile)])
@@ -127,6 +131,7 @@
                self.set_carbonfile()
                self.set_case_sensitive_readonly(rp)
                self.set_escape_dos_devices(rp)
+               self.set_escape_trailing_spaces(rp)
                return self
 
        def init_readwrite(self, rbdir):
@@ -161,6 +166,7 @@
                self.set_high_perms_readwrite(subdir)
                self.set_symlink_perms(subdir)
                self.set_escape_dos_devices(subdir)
+               self.set_escape_trailing_spaces(subdir)
 
                subdir.delete()
                return self
@@ -550,7 +556,7 @@
                sym_source.delete()
 
        def set_escape_dos_devices(self, subdir):
-               """If special file aux can be stat'd, escape special files"""
+               """If special file con can be stat'd, escape special files"""
                try:
                        device_rp = subdir.append("con")
                        if device_rp.lstat():
@@ -566,6 +572,25 @@
                                        % (subdir.path), 4)
                        self.escape_dos_devices = 1
 
+       def set_escape_trailing_spaces(self, subdir):
+               """If file with trailing space can't be created, escape such 
files"""
+               try:
+                       space_rp = subdir.append("test ")
+                       if space_rp.touch() and space_rp.lstat():
+                               log.Log("escape_trailing_spaces not required by 
filesystem " \
+                                               "at %s" % (subdir.path), 4)
+                               self.escape_trailing_spaces = 0
+                               space_rp.delete()
+                       else:
+                               log.Log("escape_trailing_spaces required by 
filesystem at %s" \
+                                               % (subdir.path), 4)
+                               self.escape_trailing_spaces = 1 
+               except(OSError):
+                       log.Log("escape_trailing_spaces required by filesystem 
at %s" \
+                                       % (subdir.path), 4)
+                       self.escape_trailing_spaces = 1
+
+
 def get_readonly_fsa(desc_string, rp):
        """Return an fsa with given description_string
 
@@ -641,6 +666,10 @@
                SetConnections.UpdateGlobal('escape_dos_devices', \
                                                                        
self.dest_fsa.escape_dos_devices)
 
+       def set_escape_trailing_spaces(self):
+               SetConnections.UpdateGlobal('escape_trailing_spaces', \
+                                                                       
self.dest_fsa.escape_trailing_spaces)
+
 class BackupSetGlobals(SetGlobals):
        """Functions for setting fsa related globals for backup session"""
        def update_triple(self, src_support, dest_support, attr_triple):
@@ -667,6 +696,21 @@
                log.Log("Backup: must_escape_dos_devices = %d" % \
                                (self.src_fsa.escape_dos_devices or local_edd), 
4)
 
+       def set_must_escape_trailing_spaces(self, rbdir):
+               """If local ets or src ets, then must escape """
+               try:
+                       space_rp = rbdir.append("test ")
+                       if space_rp.touch() and space_rp.lstat():
+                               local_ets = 0
+                               space_rp.delete()
+                       else:
+                               local_ets = 1
+               except (OSError): local_ets = 1
+               SetConnections.UpdateGlobal('must_escape_trailing_spaces', \
+                       self.src_fsa.escape_trailing_spaces or local_ets)
+               log.Log("Backup: must_escape_trailing_spaces = %d" % \
+                               (self.src_fsa.escape_trailing_spaces or 
local_ets), 4)
+
        def set_chars_to_quote(self, rbdir, force):
                """Set chars_to_quote setting for backup session
 
@@ -779,6 +823,25 @@
                log.Log("Restore: must_escape_dos_devices = %d" % \
                                (src_edd or local_edd), 4)
 
+       def set_must_escape_trailing_spaces(self, rbdir):
+               """If local ets or src ets, then must escape """
+               if getattr(self, "src_fsa", None) is not None:
+                       src_ets = self.src_fsa.escape_trailing_spaces
+               else:
+                       src_ets = 0
+               try:
+                       space_rp = rbdir.append("test ")
+                       if space_rp.touch() and space_rp.lstat():
+                               local_ets = 0
+                               space_rp.delete()
+                       else:
+                               local_ets = 1
+               except (OSError): local_ets = 1
+               SetConnections.UpdateGlobal('must_escape_trailing_spaces', \
+                       src_ets or local_ets)
+               log.Log("Restore: must_escape_trailing_spaces = %d" % \
+                               (src_ets or local_ets), 4)
+
        def set_chars_to_quote(self, rbdir):
                """Set chars_to_quote from rdiff-backup-data dir"""
                if Globals.chars_to_quote is not None: return # already 
overridden
@@ -853,7 +916,9 @@
        bsg.set_symlink_perms()
        update_quoting = bsg.set_chars_to_quote(Globals.rbdir, force)
        bsg.set_escape_dos_devices()
+       bsg.set_escape_trailing_spaces()
        bsg.set_must_escape_dos_devices(Globals.rbdir)
+       bsg.set_must_escape_trailing_spaces(Globals.rbdir)
 
        if update_quoting and force:
                FilenameMapping.update_quoting(Globals.rbdir)
@@ -881,7 +946,9 @@
        rsg.set_symlink_perms()
        rsg.set_chars_to_quote(Globals.rbdir)
        rsg.set_escape_dos_devices()
+       rsg.set_escape_trailing_spaces()
        rsg.set_must_escape_dos_devices(Globals.rbdir)
+       rsg.set_must_escape_trailing_spaces(Globals.rbdir)
 
 def single_set_globals(rp, read_only = None):
        """Set fsa related globals for operation on single filesystem"""
@@ -902,5 +969,7 @@
                ssg.set_symlink_perms()
        ssg.set_chars_to_quote(Globals.rbdir)
        ssg.set_escape_dos_devices()
+       ssg.set_escape_trailing_spaces()
        ssg.set_must_escape_dos_devices(Globals.rbdir)
+       ssg.set_must_escape_trailing_spaces(Globals.rbdir)
 




reply via email to

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