Changeset 1006:36e9d67790b1


Ignore:
Timestamp:
Dec 25, 2010, 3:27:26 PM (11 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Make sure only stat info for absolute paths is put in the cache.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ftp_stat_cache.py

    r1003 r1006  
    136136    def __setitem__(self, path, stat_result):
    137137        """
    138         Put the stat data for `path` into the cache, unless it's
    139         disabled.
     138        Put the stat data for the absolute `path` into the cache,
     139        unless it's disabled.
    140140        """
     141        assert path.startswith("/")
    141142        if not self._enabled:
    142143            return
  • test/test_ftp_stat_cache.py

    r974 r1006  
    1 # Copyright (C) 2006, Stefan Schwarzer <sschwarzer@sschwarzer.net>
     1# Copyright (C) 2006-2010, Stefan Schwarzer <sschwarzer@sschwarzer.net>
    22# See the file LICENSE for licensing terms.
    33
     
    1717    def test_get_set(self):
    1818        self.assertRaises(ftp_error.CacheMissError,
    19                           self.cache.__getitem__, "path")
    20         self.cache["path"] = "test"
    21         self.assertEqual(self.cache["path"], "test")
     19                          self.cache.__getitem__, "/path")
     20        self.cache["/path"] = "test"
     21        self.assertEqual(self.cache["/path"], "test")
    2222
    2323    def test_invalidate(self):
     
    2929
    3030    def test_clear(self):
    31         self.cache["path1"] = "test1"
    32         self.cache["path2"] = "test2"
     31        self.cache["/path1"] = "test1"
     32        self.cache["/path2"] = "test2"
    3333        self.cache.clear()
    3434        self.assertEqual(len(self.cache), 0)
    3535
    3636    def test_contains(self):
    37         self.cache["path1"] = "test1"
    38         self.assertEqual("path1" in self.cache, True)
    39         self.assertEqual("path2" in self.cache, False)
     37        self.cache["/path1"] = "test1"
     38        self.assertEqual("/path1" in self.cache, True)
     39        self.assertEqual("/path2" in self.cache, False)
    4040
    4141    def test_len(self):
    4242        self.assertEqual(len(self.cache), 0)
    43         self.cache["path1"] = "test1"
    44         self.cache["path2"] = "test2"
     43        self.cache["/path1"] = "test1"
     44        self.cache["/path2"] = "test2"
    4545        self.assertEqual(len(self.cache), 2)
    4646
Note: See TracChangeset for help on using the changeset viewer.