mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-22 10:20:59 +00:00
Show -IMM and -RO suffixes for types of immutable and read-only unknown nodes in directory listings
This commit is contained in:
parent
1bb627405f
commit
4560e021a9
@ -3256,13 +3256,16 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
|
|||||||
|
|
||||||
# make sure directory listing tolerates unknown nodes
|
# make sure directory listing tolerates unknown nodes
|
||||||
d.addCallback(lambda ign: self.GET(self.rooturl))
|
d.addCallback(lambda ign: self.GET(self.rooturl))
|
||||||
def _check_directory_html(res):
|
def _check_directory_html(res, expected_type_suffix):
|
||||||
self.failUnlessIn("<td>%s</td>" % (str(name),), res)
|
pattern = re.compile(r'<td>\?%s</td>[ \t\n\r]*'
|
||||||
|
'<td>%s</td>' % (expected_type_suffix, str(name)),
|
||||||
|
re.DOTALL)
|
||||||
|
self.failUnless(re.search(pattern, res), res)
|
||||||
# find the More Info link for name, should be relative
|
# find the More Info link for name, should be relative
|
||||||
mo = re.search(r'<a href="([^"]+)">More Info</a>', res)
|
mo = re.search(r'<a href="([^"]+)">More Info</a>', res)
|
||||||
info_url = mo.group(1)
|
info_url = mo.group(1)
|
||||||
self.failUnlessEqual(info_url, "%s?t=info" % (str(name),))
|
self.failUnlessEqual(info_url, "%s?t=info" % (str(name),))
|
||||||
d.addCallback(_check_directory_html)
|
d.addCallback(_check_directory_html, "-IMM" if immutable else "")
|
||||||
|
|
||||||
d.addCallback(lambda ign: self.GET(self.rooturl+"?t=json"))
|
d.addCallback(lambda ign: self.GET(self.rooturl+"?t=json"))
|
||||||
def _check_directory_json(res, expect_rw_uri):
|
def _check_directory_json(res, expect_rw_uri):
|
||||||
@ -3320,7 +3323,7 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
|
|||||||
# rendered too. This version will not have future_write_uri, whether
|
# rendered too. This version will not have future_write_uri, whether
|
||||||
# or not future_node was immutable.
|
# or not future_node was immutable.
|
||||||
d.addCallback(lambda ign: self.GET(self.rourl))
|
d.addCallback(lambda ign: self.GET(self.rourl))
|
||||||
d.addCallback(_check_directory_html)
|
d.addCallback(_check_directory_html, "-IMM" if immutable else "-RO")
|
||||||
d.addCallback(lambda ign: self.GET(self.rourl+"?t=json"))
|
d.addCallback(lambda ign: self.GET(self.rourl+"?t=json"))
|
||||||
d.addCallback(_check_directory_json, expect_rw_uri=False)
|
d.addCallback(_check_directory_json, expect_rw_uri=False)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ from nevow.inevow import IRequest
|
|||||||
from foolscap.api import fireEventually
|
from foolscap.api import fireEventually
|
||||||
|
|
||||||
from allmydata.util import base32, time_format
|
from allmydata.util import base32, time_format
|
||||||
from allmydata.uri import from_string_dirnode
|
from allmydata.uri import from_string_dirnode, ALLEGED_IMMUTABLE_PREFIX
|
||||||
from allmydata.interfaces import IDirectoryNode, IFileNode, IFilesystemNode, \
|
from allmydata.interfaces import IDirectoryNode, IFileNode, IFilesystemNode, \
|
||||||
IImmutableFileNode, IMutableFileNode, ExistingChildError, \
|
IImmutableFileNode, IMutableFileNode, ExistingChildError, \
|
||||||
NoSuchChildError, EmptyPathnameComponentError
|
NoSuchChildError, EmptyPathnameComponentError
|
||||||
@ -737,7 +737,13 @@ class DirectoryAsHTML(rend.Page):
|
|||||||
else:
|
else:
|
||||||
# unknown
|
# unknown
|
||||||
ctx.fillSlots("filename", html.escape(name))
|
ctx.fillSlots("filename", html.escape(name))
|
||||||
ctx.fillSlots("type", "?")
|
if target.get_write_uri() is not None:
|
||||||
|
unknowntype = "?"
|
||||||
|
elif not self.node.is_mutable() or target.get_readonly_uri().startswith(ALLEGED_IMMUTABLE_PREFIX):
|
||||||
|
unknowntype = "?-IMM"
|
||||||
|
else:
|
||||||
|
unknowntype = "?-RO"
|
||||||
|
ctx.fillSlots("type", unknowntype)
|
||||||
ctx.fillSlots("size", "-")
|
ctx.fillSlots("size", "-")
|
||||||
# use a directory-relative info link, so we can extract both the
|
# use a directory-relative info link, so we can extract both the
|
||||||
# writecap and the readcap
|
# writecap and the readcap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user