Exemplo n.º 1
0
 def test_toplevel_addition_causes_change(self):
   c = DirCache()
   base = self.test_data.path_to('');
   c.listdir(base)
   self.assertFalse(c.listdir_with_changed_status(base)[1])
   time.sleep(1.2)
   self.test_data.write1('READMEx')
   self.assertTrue(c.listdir_with_changed_status(base)[1])
Exemplo n.º 2
0
 def test_toplevel_deletion_causes_changed(self):
   c = DirCache()
   base = self.test_data.path_to('');
   something = self.test_data.path_to('something');
   c.listdir(base)
   c.listdir(something)
   self.assertFalse(c.listdir_with_changed_status(base)[1])
   self.assertFalse(c.listdir_with_changed_status(something)[1])
   time.sleep(1.2)
   self.test_data.rm_rf(something)
   self.assertTrue(c.listdir_with_changed_status(base)[1])
   self.assertTrue(c.listdir_with_changed_status(something)[1])
Exemplo n.º 3
0
  def __init__(self, settings):
    self.settings = settings
    self.needs_indexing = Event() # fired when the database gets dirtied and needs syncing
    self._pending_indexer = None # non-None if a DBIndex is running
    self._cur_index = None # the last DBIndex object --> actually runs the searches

    self._dir_cache = DirCache() # thread only state

    # if we are currently looking for changed dirs, this is the iterator
    # directories remaining to be checked
    self._pending_up_to_date_generator = None 

    self.settings.register('dirs', list, [], self._on_settings_dirs_changed)
    self._on_settings_dirs_changed(None, self.settings.dirs)

    self.settings.register('ignores', list, [], self._on_settings_ignores_changed)
    if self.settings.ignores == []:
	self.settings.ignores = DEFAULT_IGNORES;

    self._on_settings_ignores_changed(None, self.settings.ignores)
Exemplo n.º 4
0
    def __init__(self, settings):
        self.settings = settings
        self.needs_indexing = Event(
        )  # fired when the database gets dirtied and needs syncing
        self._pending_indexer = None  # non-None if a DBIndexer is running
        self._cur_shard_manager = None  # the current DBShardManager object. This has all the DBIndexShards.
        self._cur_query_cache = None

        self._dir_cache = DirCache()  # thread only state

        self.settings.register('dirs', list, [],
                               self._on_settings_dirs_changed)
        self._on_settings_dirs_changed(None, self.settings.dirs)

        self.settings.register('ignores', list, [],
                               self._on_settings_ignores_changed)
        if self.settings.ignores == []:
            self.settings.ignores = DEFAULT_IGNORES

        self._on_settings_ignores_changed(None, self.settings.ignores)

        self.settings.register('token', str, "",
                               self._on_settings_token_changed)
        self._on_settings_token_changed(None, self.settings.token)
Exemplo n.º 5
0
 def test_up_to_date_after_change(self):
   c = DirCache()
   something = self.test_data.path_to('something');
   c.listdir(something)
   self.test_data.rm_rf(something)
   self.assertEquals([], c.listdir(self.test_data.path_to('something')))
Exemplo n.º 6
0
 def test_listdir_when_gone(self):
   c = DirCache()
   something = self.test_data.path_to('something');
   c.listdir(something)
   self.test_data.rm_rf(something)
   self.assertEquals([], c.listdir(self.test_data.path_to('something')))
Exemplo n.º 7
0
 def test_listdir_on_invalid_dir(self):
   c = DirCache()
   # shoudl not raise exception
   c.listdir(self.test_data.path_to('xxx'))