def is_ignored(self, path):
        """should we ignore this path?"""
        # check first if the platform code knows hat to do with it
        if not self.platform_is_ignored(path):
            # check if we can read
            if path_exists(path) and not access(path):
                self.log.warning("Ignoring path as we don't have enough "
                                 "permissions to track it: %r", path)
                return True

            is_conflict = self.conflict_RE.search
            dirname, filename = os.path.split(path)
            # ignore conflicts
            if is_conflict(filename):
                return True
            # ignore partial downloads
            if filename == '.u1partial' or filename.startswith('.u1partial.'):
                return True

            # and ignore paths that are inside conflicts (why are we even
            # getting the event?)
            if any(part.endswith('.u1partial') or is_conflict(part)
                   for part in dirname.split(os.path.sep)):
                return True

            if self.ignore_RE is not None and self.ignore_RE.match(filename):
                return True

            return False
        return True
Ejemplo n.º 2
0
 def add_watches_to_udf_ancestors(self, volume):
     """Add a inotify watch to volume's ancestors if it's an UDF."""
     # This is a platform dependent operation since there are cases in
     # which the watches do not have to be added (On windows we do not
     # have to add them since we have an opened handle.)
     # finally, check that UDF is ok in disk
     if not access(volume.path):
         # if we cannot access the UDF lets return false and do
         # nothing
         return defer.succeed(False)
     return self.monitor.add_watches_to_udf_ancestors(volume)
Ejemplo n.º 3
0
        def scan():
            """The scan, really."""

            log_debug("scanning the dir %r", dirpath)
            dircontent = listdir(dirpath)

            # get the info from disk
            dnames = []
            fnames = []
            for something in dircontent:
                fullname = os.path.join(dirpath, something)
                stat_result = get_stat(fullname)
                if stat_result is None:
                    # gone between the listdir and now
                    continue
                if is_link(fullname):
                    log_info("Ignoring path as it's a symlink: %r", fullname)
                    continue
                if not is_valid_name(fullname):
                    m = "Ignoring path because it's invalid (non utf8): %r"
                    log_info(m, fullname)
                    continue
                if not access(fullname):
                    log_warning("Ignoring path as we don't have enough "
                                "permissions to track it: %r", fullname)
                    continue

                if stat.S_ISDIR(stat_result.st_mode):
                    dnames.append(something)
                elif stat.S_ISREG(stat_result.st_mode):
                    fnames.append(something)
                else:
                    log_warning("Path: %r isn't a dir, file or symlink.",
                                fullname)

            events, to_scan_later = self._compare(dirpath, dnames, fnames,
                                                  share)
            to_later.extend(to_scan_later)
            return events
Ejemplo n.º 4
0
 def test_access_nothing(self):
     """Test access on a file with no permission at all."""
     set_no_rights(self.testfile)
     self.addCleanup(set_file_readwrite, self.testfile)
     self.assertFalse(access(self.testfile))
Ejemplo n.º 5
0
 def test_access_ro(self):
     """Test access on a file with read only permission."""
     set_file_readonly(self.testfile)
     self.addCleanup(set_file_readwrite, self.testfile)
     self.assertTrue(access(self.testfile))
Ejemplo n.º 6
0
 def test_access_rw(self):
     """Test access on a file with full permission."""
     self.assertTrue(access(self.testfile))