diff --git a/docs/configuration.rst b/docs/configuration.rst index 8abcb5d76..b7e85ecbb 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -784,6 +784,14 @@ Storage Server Configuration .. _#390: https://tahoe-lafs.org/trac/tahoe-lafs/ticket/390 +``storage_dir = (string, optional)`` + + This specifies a storing directory. + + The default value is the ``storage`` directory in the node's base directory + (i.e. ``BASEDIR/storage``), but it can be placed elsewhere. Relative paths + will be interpreted relative to the node's base directory. + Running A Helper ================ @@ -1105,16 +1113,16 @@ a legal one. log_gatherer.furl = pb://soklj4y7eok5c3xkmjeqpw@192.168.69.247:44801/eqpwqtzm timeout.keepalive = 240 timeout.disconnect = 1800 - + [client] introducer.furl = pb://ok45ssoklj4y7eok5c3xkmj@tcp:tahoe.example:44801/ii3uumo helper.furl = pb://ggti5ssoklj4y7eok5c3xkmj@tcp:helper.tahoe.example:7054/kk8lhr - + [storage] enabled = True readonly = True reserved_space = 10000000000 - + [helper] enabled = True diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 027372a20..f15e8794e 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -350,7 +350,8 @@ class _Client(node.Node, pollmixin.PollMixin): "is not listening ('tub.port=' is empty)") readonly = self.get_config("storage", "readonly", False, boolean=True) - storedir = os.path.join(self.basedir, self.STOREDIR) + config_storedir = self.get_config("storage", "storage_dir", self.STOREDIR).decode('utf-8') + storedir = os.path.join(self.basedir, config_storedir) data = self.get_config("storage", "reserved_space", None) try: diff --git a/src/allmydata/scripts/create_node.py b/src/allmydata/scripts/create_node.py index 1d71996f0..2f6bf3e78 100644 --- a/src/allmydata/scripts/create_node.py +++ b/src/allmydata/scripts/create_node.py @@ -177,7 +177,8 @@ class CreateClientOptions(_CreateBaseOptions): class CreateNodeOptions(CreateClientOptions): optFlags = [ ("no-storage", None, "Do not offer storage service to other nodes."), - ] + TOR_FLAGS + I2P_FLAGS + ("storage-dir", "s", None, "Path where the storage will be placed."), + ] + TOR_FLAGS + I2P_FLAGS synopsis = "[options] [NODEDIR]" description = "Create a full Tahoe-LAFS node (client+server)." @@ -320,6 +321,11 @@ def write_client_config(c, config): c.write("enabled = %s\n" % boolstr[storage_enabled]) c.write("#readonly =\n") c.write("reserved_space = 1G\n") + storage_dir = config.get("storage-dir") + if storage_dir: + c.write("storage_dir = %s\n" % (storage_dir,)) + else: + c.write("#storage_dir =\n") c.write("#expire.enabled =\n") c.write("#expire.mode =\n") c.write("\n") diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index 1576fd319..525a0ce8e 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -12,6 +12,7 @@ from allmydata.frontends.auth import NeedRootcapLookupScheme from allmydata import client from allmydata.storage_client import StorageFarmBroker from allmydata.util import base32, fileutil +from allmydata.util.fileutil import abspath_expanduser_unicode from allmydata.interfaces import IFilesystemNode, IFileNode, \ IImmutableFileNode, IMutableFileNode, IDirectoryNode from foolscap.api import flushEventualQueue @@ -251,6 +252,18 @@ class Basic(testutil.ReallyEqualMixin, testutil.NonASCIIPathMixin, unittest.Test "port = tcp:0:interface=127.0.0.1\n")) self.failUnlessRaises(NeedRootcapLookupScheme, client.create_client, basedir) + def test_storage_dir(self): + basedir = u"client.Basic.test_storage_dir" + os.mkdir(basedir) + fileutil.write(os.path.join(basedir, "tahoe.cfg"), + BASECONFIG + + "[storage]\n" + + "enabled = true\n" + + "storage_dir = myowndir\n") + c = client.Client(basedir) + self.failUnlessEqual(c.getServiceNamed("storage").storedir, + os.path.join(abspath_expanduser_unicode(basedir), u"myowndir")) + def _permute(self, sb, key): return [ s.get_longname() for s in sb.get_servers_for_psi(key) ]