Beispiel #1
0
 def _scanIndexFolder(self):
     '''
     Scan the index directory and rebuild the index cache
     '''
     files = sorted([path.join(self._diskerDirectory, x)\
               for x in os.listdir(self._diskerDirectory)\
               if x.endswith(Index.INDEX_EXTENSION)])
     for f in [x for x in files if path.isfile(x)]:
         index = Index()
         if index.loadIndexFile(f):
             self._addIndex(f, index)
Beispiel #2
0
    def _on_disker_directory_changed(self, filemonitor, file1, file2,
                                     event_type):
        '''
        This callback is triggered when the disker directory has been modified.
        If and index file has been removed and the index is in our internal
        indexes cache, we remove it. If a new index file has been created or
        modified, we parse it and we add it to the internal indexes cache.
        '''
        if event_type == gio.FILE_MONITOR_EVENT_DELETED:
            # A file has been deleted, check if it's one of the indexes we have
            # in the cache and remove it
            if file1 and file1.get_path() in self._indexes:
                del self._indexes[file1.get_path()]

        elif event_type == gio.FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
            # A file has been created or modified. Check if it's and index
            # file, parse it and add to the internal cache
            if not file1 or\
                        not file1.get_path().endswith(Index.INDEX_EXTENSION):
                return
            index = Index()
            if index.loadIndexFile(file1.get_path()):
                self._addIndex(file1.get_path(), index)