mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-22 10:20:59 +00:00
Add storage_dir config field
On the [storage] section of the tahoe.cfg now there is a field 'storage_dir' where the path to the storage folder can be configured.
This commit is contained in:
parent
a1cb401f06
commit
136de7d7f7
@ -784,6 +784,14 @@ Storage Server Configuration
|
|||||||
|
|
||||||
.. _#390: https://tahoe-lafs.org/trac/tahoe-lafs/ticket/390
|
.. _#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
|
Running A Helper
|
||||||
================
|
================
|
||||||
|
@ -350,7 +350,8 @@ class _Client(node.Node, pollmixin.PollMixin):
|
|||||||
"is not listening ('tub.port=' is empty)")
|
"is not listening ('tub.port=' is empty)")
|
||||||
readonly = self.get_config("storage", "readonly", False, boolean=True)
|
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)
|
data = self.get_config("storage", "reserved_space", None)
|
||||||
try:
|
try:
|
||||||
|
@ -177,6 +177,7 @@ class CreateClientOptions(_CreateBaseOptions):
|
|||||||
class CreateNodeOptions(CreateClientOptions):
|
class CreateNodeOptions(CreateClientOptions):
|
||||||
optFlags = [
|
optFlags = [
|
||||||
("no-storage", None, "Do not offer storage service to other nodes."),
|
("no-storage", None, "Do not offer storage service to other nodes."),
|
||||||
|
("storage-dir", "s", None, "Path where the storage will be placed."),
|
||||||
] + TOR_FLAGS + I2P_FLAGS
|
] + TOR_FLAGS + I2P_FLAGS
|
||||||
|
|
||||||
synopsis = "[options] [NODEDIR]"
|
synopsis = "[options] [NODEDIR]"
|
||||||
@ -320,6 +321,11 @@ def write_client_config(c, config):
|
|||||||
c.write("enabled = %s\n" % boolstr[storage_enabled])
|
c.write("enabled = %s\n" % boolstr[storage_enabled])
|
||||||
c.write("#readonly =\n")
|
c.write("#readonly =\n")
|
||||||
c.write("reserved_space = 1G\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.enabled =\n")
|
||||||
c.write("#expire.mode =\n")
|
c.write("#expire.mode =\n")
|
||||||
c.write("\n")
|
c.write("\n")
|
||||||
|
@ -12,6 +12,7 @@ from allmydata.frontends.auth import NeedRootcapLookupScheme
|
|||||||
from allmydata import client
|
from allmydata import client
|
||||||
from allmydata.storage_client import StorageFarmBroker
|
from allmydata.storage_client import StorageFarmBroker
|
||||||
from allmydata.util import base32, fileutil
|
from allmydata.util import base32, fileutil
|
||||||
|
from allmydata.util.fileutil import abspath_expanduser_unicode
|
||||||
from allmydata.interfaces import IFilesystemNode, IFileNode, \
|
from allmydata.interfaces import IFilesystemNode, IFileNode, \
|
||||||
IImmutableFileNode, IMutableFileNode, IDirectoryNode
|
IImmutableFileNode, IMutableFileNode, IDirectoryNode
|
||||||
from foolscap.api import flushEventualQueue
|
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"))
|
"port = tcp:0:interface=127.0.0.1\n"))
|
||||||
self.failUnlessRaises(NeedRootcapLookupScheme, client.create_client, basedir)
|
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):
|
def _permute(self, sb, key):
|
||||||
return [ s.get_longname() for s in sb.get_servers_for_psi(key) ]
|
return [ s.get_longname() for s in sb.get_servers_for_psi(key) ]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user