~m4ktub/duplicity/0.7-fixes

« back to all changes in this revision

Viewing changes to duplicity/selection.py

* Merged in lp:~aaron-whitehouse/duplicity/bug_1620085_exclude-if-present-locked-folder
  - Fixes Bug #1620085: --exclude-if-present gives OSError looking for tag in locked folders

Show diffs side-by-side

added added

removed removed

Lines of Context:
447
447
 
448
448
        def exclude_sel_func(path):
449
449
            # do not follow symbolic links when checking for file existence!
450
 
            if path.isdir() and path.append(filename).exists():
451
 
                return 0
452
 
            else:
453
 
                return None
 
450
            if path.isdir():
 
451
                # First check path is read accessible
 
452
                if not (os.access(path.name, os.R_OK)):
 
453
                    # Path is not read accessible
 
454
                    # ToDo: Ideally this error would only show if the folder
 
455
                    # was ultimately included by the full set of selection
 
456
                    # functions. Currently this will give an error for any
 
457
                    # locked directory within the folder being backed up.
 
458
                    log.Warn(_(
 
459
                        "Error accessing possibly locked file %s") % util.ufn(
 
460
                        path.name),
 
461
                        log.WarningCode.cannot_read, util.escape(path.name))
 
462
                    if diffdir.stats:
 
463
                        diffdir.stats.Errors += 1
 
464
                elif path.append(filename).exists():
 
465
                    return 0
 
466
                else:
 
467
                    return None
454
468
 
455
469
        if include == 0:
456
470
            sel_func = exclude_sel_func