mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 18:56:28 +00:00
webapi: fix t=check for DIR2-LIT (i.e. empty immutable directories)
This commit is contained in:
parent
41bcc9f39e
commit
366a309795
@ -2782,6 +2782,8 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
|
||||
d.addCallback(lambda ign:
|
||||
c0.upload(upload.Data("literal", convergence="")))
|
||||
d.addCallback(_stash_uri, "small")
|
||||
d.addCallback(lambda ign: c0.create_immutable_dirnode({}))
|
||||
d.addCallback(_stash_mutable_uri, "smalldir")
|
||||
|
||||
def _compute_fileurls(ignored):
|
||||
self.fileurls = {}
|
||||
@ -2844,6 +2846,18 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
|
||||
self.failUnless(r["results"]["healthy"])
|
||||
d.addCallback(_got_json_small)
|
||||
|
||||
d.addCallback(self.CHECK, "smalldir", "t=check")
|
||||
def _got_html_smalldir(res):
|
||||
self.failUnless("Literal files are always healthy" in res, res)
|
||||
self.failIf("Not Healthy" in res, res)
|
||||
d.addCallback(_got_html_smalldir)
|
||||
d.addCallback(self.CHECK, "smalldir", "t=check&output=json")
|
||||
def _got_json_smalldir(res):
|
||||
r = simplejson.loads(res)
|
||||
self.failUnlessEqual(r["storage-index"], "")
|
||||
self.failUnless(r["results"]["healthy"])
|
||||
d.addCallback(_got_json_smalldir)
|
||||
|
||||
d.addCallback(self.CHECK, "sick", "t=check")
|
||||
def _got_html_sick(res):
|
||||
self.failUnless("Not Healthy" in res, res)
|
||||
|
@ -26,7 +26,8 @@ from allmydata.web.common import text_plain, WebError, \
|
||||
from allmydata.web.filenode import ReplaceMeMixin, \
|
||||
FileNodeHandler, PlaceHolderNodeHandler
|
||||
from allmydata.web.check_results import CheckResults, \
|
||||
CheckAndRepairResults, DeepCheckResults, DeepCheckAndRepairResults
|
||||
CheckAndRepairResults, DeepCheckResults, DeepCheckAndRepairResults, \
|
||||
LiteralCheckResults
|
||||
from allmydata.web.info import MoreInfo
|
||||
from allmydata.web.operations import ReloadMixin
|
||||
from allmydata.web.check_results import json_check_results, \
|
||||
@ -397,6 +398,11 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
||||
d.addCallback(lambda res: "thing renamed")
|
||||
return d
|
||||
|
||||
def _maybe_literal(self, res, Results_Class):
|
||||
if res:
|
||||
return Results_Class(self.client, res)
|
||||
return LiteralCheckResults(self.client)
|
||||
|
||||
def _POST_check(self, req):
|
||||
# check this directory
|
||||
verify = boolean_of_arg(get_arg(req, "verify", "false"))
|
||||
@ -404,10 +410,10 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
||||
add_lease = boolean_of_arg(get_arg(req, "add-lease", "false"))
|
||||
if repair:
|
||||
d = self.node.check_and_repair(Monitor(), verify, add_lease)
|
||||
d.addCallback(lambda res: CheckAndRepairResults(self.client, res))
|
||||
d.addCallback(self._maybe_literal, CheckAndRepairResults)
|
||||
else:
|
||||
d = self.node.check(Monitor(), verify, add_lease)
|
||||
d.addCallback(lambda res: CheckResults(self.client, res))
|
||||
d.addCallback(self._maybe_literal, CheckResults)
|
||||
return d
|
||||
|
||||
def _start_operation(self, monitor, renderer, ctx):
|
||||
|
@ -9,7 +9,6 @@ from nevow.inevow import IRequest
|
||||
from allmydata.interfaces import ExistingChildError, CannotPackUnknownNodeError
|
||||
from allmydata.monitor import Monitor
|
||||
from allmydata.immutable.upload import FileHandle
|
||||
from allmydata.immutable.filenode import LiteralFileNode
|
||||
from allmydata.unknown import UnknownNode
|
||||
from allmydata.util import log, base32
|
||||
|
||||
@ -260,18 +259,21 @@ class FileNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
||||
d.addCallback(lambda res: url.URL.fromString(when_done))
|
||||
return d
|
||||
|
||||
def _maybe_literal(self, res, Results_Class):
|
||||
if res:
|
||||
return Results_Class(self.client, res)
|
||||
return LiteralCheckResults(self.client)
|
||||
|
||||
def _POST_check(self, req):
|
||||
verify = boolean_of_arg(get_arg(req, "verify", "false"))
|
||||
repair = boolean_of_arg(get_arg(req, "repair", "false"))
|
||||
add_lease = boolean_of_arg(get_arg(req, "add-lease", "false"))
|
||||
if isinstance(self.node, LiteralFileNode):
|
||||
return defer.succeed(LiteralCheckResults(self.client))
|
||||
if repair:
|
||||
d = self.node.check_and_repair(Monitor(), verify, add_lease)
|
||||
d.addCallback(lambda res: CheckAndRepairResults(self.client, res))
|
||||
d.addCallback(self._maybe_literal, CheckAndRepairResults)
|
||||
else:
|
||||
d = self.node.check(Monitor(), verify, add_lease)
|
||||
d.addCallback(lambda res: CheckResults(self.client, res))
|
||||
d.addCallback(self._maybe_literal, CheckResults)
|
||||
return d
|
||||
|
||||
def render_DELETE(self, ctx):
|
||||
|
Loading…
Reference in New Issue
Block a user