]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - src/allmydata/mutable/common.py
Remove ResponseCache in favor of MDMFSlotReadProxy's cache. closes #1240.
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / mutable / common.py
1
2 MODE_CHECK = "MODE_CHECK" # query all peers
3 MODE_ANYTHING = "MODE_ANYTHING" # one recoverable version
4 MODE_WRITE = "MODE_WRITE" # replace all shares, probably.. not for initial
5                           # creation
6 MODE_READ = "MODE_READ"
7 MODE_REPAIR = "MODE_REPAIR" # query all peers, get the privkey
8
9 class NotWriteableError(Exception):
10     pass
11
12 class BadShareError(Exception):
13     """This represents an error discovered in a particular share, during
14     retrieve, from which we can recover by using some other share. This does
15     *not* include local coding errors.
16     """
17
18 class NeedMoreDataError(BadShareError):
19     def __init__(self, needed_bytes, encprivkey_offset, encprivkey_length):
20         Exception.__init__(self)
21         self.needed_bytes = needed_bytes # up through EOF
22         self.encprivkey_offset = encprivkey_offset
23         self.encprivkey_length = encprivkey_length
24     def __repr__(self):
25         return "<NeedMoreDataError (%d bytes)>" % self.needed_bytes
26
27 class UncoordinatedWriteError(Exception):
28     def __repr__(self):
29         return ("<%s -- You, oh user, tried to change a file or directory "
30                 "at the same time as another process was trying to change it. "
31                 " To avoid data loss, don't do this.  Please see "
32                 "docs/write_coordination.rst for details.>" %
33                 (self.__class__.__name__,))
34
35 class UnrecoverableFileError(Exception):
36     pass
37
38 class NotEnoughServersError(Exception):
39     """There were not enough functioning servers available to place shares
40     upon. This might result from all servers being full or having an error, a
41     local bug which causes all server requests to fail in the same way, or
42     from there being zero servers. The first error received (if any) is
43     stored in my .first_error attribute."""
44     def __init__(self, why, first_error=None):
45         Exception.__init__(self, why, first_error)
46         self.first_error = first_error
47
48 class CorruptShareError(BadShareError):
49     def __init__(self, server, shnum, reason):
50         self.args = (server, shnum, reason)
51         self.server = server
52         self.shnum = shnum
53         self.reason = reason
54     def __str__(self):
55         return "<CorruptShareError server=%s shnum[%d]: %s" % \
56                (self.server.get_name(), self.shnum, self.reason)
57
58 class UnknownVersionError(BadShareError):
59     """The share we received was of a version we don't recognize."""