diff --git a/src/allmydata/storage/common.py b/src/allmydata/storage/common.py index 695c044e0..a442dbf4a 100644 --- a/src/allmydata/storage/common.py +++ b/src/allmydata/storage/common.py @@ -1,4 +1,17 @@ +import os.path +from allmydata.util import base32 + class DataTooLargeError(Exception): pass + +def si_b2a(storageindex): + return base32.b2a(storageindex) + +def si_a2b(ascii_storageindex): + return base32.a2b(ascii_storageindex) + +def storage_index_to_dir(storageindex): + sia = si_b2a(storageindex) + return os.path.join(sia[:2], sia) diff --git a/src/allmydata/storage/crawler.py b/src/allmydata/storage/crawler.py index abdb0db43..435bd2faa 100644 --- a/src/allmydata/storage/crawler.py +++ b/src/allmydata/storage/crawler.py @@ -3,7 +3,7 @@ import os, time, struct import cPickle as pickle from twisted.internet import reactor from twisted.application import service -from allmydata.storage.server import si_b2a +from allmydata.storage.common import si_b2a from allmydata.util import fileutil class TimeSliceExceeded(Exception): diff --git a/src/allmydata/storage/server.py b/src/allmydata/storage/server.py index 4840cc53f..96e5b6ab6 100644 --- a/src/allmydata/storage/server.py +++ b/src/allmydata/storage/server.py @@ -8,6 +8,8 @@ from allmydata.interfaces import RIStorageServer, IStatsProducer from allmydata.util import base32, fileutil, log, time_format import allmydata # for __full_version__ +from allmydata.storage.common import si_b2a, si_a2b, storage_index_to_dir +_pyflakes_hush = [si_b2a, si_a2b, storage_index_to_dir] # re-exported from allmydata.storage.lease import LeaseInfo from allmydata.storage.mutable import MutableShareFile, EmptyShare, \ create_mutable_sharefile @@ -26,16 +28,6 @@ from allmydata.storage.immutable import ShareFile, BucketWriter, BucketReader # $SHARENUM matches this regex: NUM_RE=re.compile("^[0-9]+$") -def si_b2a(storageindex): - return base32.b2a(storageindex) - -def si_a2b(ascii_storageindex): - return base32.a2b(ascii_storageindex) - -def storage_index_to_dir(storageindex): - sia = si_b2a(storageindex) - return os.path.join(sia[:2], sia) - class StorageServer(service.MultiService, Referenceable):