This file is indexed.

/usr/share/pyshared/allmydata/util/cachedir.py is in tahoe-lafs 1.9.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os.path, stat, weakref, time
from twisted.application import service, internet
from allmydata.util import fileutil

HOUR = 60*60

class CacheDirectoryManager(service.MultiService):
    def __init__(self, basedir, pollinterval=1*HOUR, old=1*HOUR):
        service.MultiService.__init__(self)
        self.basedir = basedir
        fileutil.make_dirs(basedir)
        self.old = old
        self.files = weakref.WeakValueDictionary()

        t = internet.TimerService(pollinterval, self.check)
        t.setServiceParent(self)

    def get_file(self, key):
        assert isinstance(key, str) # used as filename
        absfn = os.path.join(self.basedir, key)
        if os.path.exists(absfn):
            os.utime(absfn, None)
        cf = CacheFile(absfn)
        self.files[key] = cf
        return cf

    def check(self):
        now = time.time()
        for fn in os.listdir(self.basedir):
            if fn in self.files:
                continue
            absfn = os.path.join(self.basedir, fn)
            mtime = os.stat(absfn)[stat.ST_MTIME]
            if now - mtime > self.old:
                os.remove(absfn)

class CacheFile:
    def __init__(self, absfn):
        self.filename = absfn

    def get_filename(self):
        return self.filename