Ticket #443: imm-dir-etag.diff.txt

File imm-dir-etag.diff.txt, 2.9 KB (added by jsgf, at 2010-03-12T00:00:24Z)

Add ETag support for immutable directories

Line 
1Thu Mar 11 15:47:14 PST 2010  Jeremy Fitzhardinge <jeremy@goop.org>
2  * Add ETags for immutable directories
3 
4  Like immutable files, the ETag is based on the storage index.
5  However, since a directory is a special interpretation of a file, it is
6  distinguished from the file by prepending "DIR:" onto the start of the
7  ETag, and adding -representation on the end (where -representation is
8  the ?t= argument, json, info, etc).
9 
10  It also checks the return of setETag and avoids generating a
11  representation if the client already has it.
12 
13
14New patches:
15
16[Add ETags for immutable directories
17Jeremy Fitzhardinge <jeremy@goop.org>**20100311234714
18 Ignore-this: b2b8f1c91af5e83b3c8d1441d658a15d
19 
20 Like immutable files, the ETag is based on the storage index.
21 However, since a directory is a special interpretation of a file, it is
22 distinguished from the file by prepending "DIR:" onto the start of the
23 ETag, and adding -representation on the end (where -representation is
24 the ?t= argument, json, info, etc).
25 
26 It also checks the return of setETag and avoids generating a
27 representation if the client already has it.
28 
29] {
30hunk ./src/allmydata/web/directory.py 148
31 
32     def render_GET(self, ctx):
33         req = IRequest(ctx)
34+
35         # This is where all of the directory-related ?t=* code goes.
36         t = get_arg(req, "t", "").strip()
37hunk ./src/allmydata/web/directory.py 151
38+
39+        if not self.node.is_mutable():
40+            si = self.node.get_storage_index()
41+            if si and req.setETag('DIR:%s-%s' % (base32.b2a(si), t or "")):
42+                    return ""
43+
44         if not t:
45             # render the directory as HTML, using the docFactory and Nevow's
46             # whole templating thing.
47}
48
49Context:
50
51[setup: add licensing declaration for setuptools (noticed by the FSF compliance folks)
52zooko@zooko.com**20100309184415
53 Ignore-this: 2dfa7d812d65fec7c72ddbf0de609ccb
54]
55[setup: fix error in licensing declaration from Shawn Willden, as noted by the FSF compliance division
56zooko@zooko.com**20100309163736
57 Ignore-this: c0623d27e469799d86cabf67921a13f8
58]
59[CREDITS to Jacob Appelbaum
60zooko@zooko.com**20100304015616
61 Ignore-this: 70db493abbc23968fcc8db93f386ea54
62]
63[desert-island-build-with-proper-versions
64jacob@appelbaum.net**20100304013858]
65[docs: a few small edits to try to guide newcomers through the docs
66zooko@zooko.com**20100303231902
67 Ignore-this: a6aab44f5bf5ad97ea73e6976bc4042d
68 These edits were suggested by my watching over Jake Appelbaum's shoulder as he completely ignored/skipped/missed install.html and also as he decided that debian.txt wouldn't help him with basic installation. Then I threw in a few docs edits that have been sitting around in my sandbox asking to be committed for months.
69]
70[TAG allmydata-tahoe-1.6.1
71david-sarah@jacaranda.org**20100228062314
72 Ignore-this: eb5f03ada8ea953ee7780e7fe068539
73]
74Patch bundle hash:
75e39fc8874aa7dee40857867f2ea2653a62403182