[tahoe-dev] change to storage layout

zooko zooko at zooko.com
Thu Feb 14 14:00:55 UTC 2008


Folks:

As of changeset [2136] -- 2008-02-12, the organization of shares on  
storage servers has changed to use base62 encoding instead of  
base32.  If you run a storage server and you want it to find and  
serve up shares which it wrote to its disk before [2136], then you  
should execute the attached "convertshares.py" script in your  
$BASEDIR/storage/shares directory.  (This script will also convert  
shares which were written before [2031] -- 2008-01-31.)

Regards,

Zooko

changesets mentioned in this e-mail:

http://allmydata.org/trac/tahoe/changeset/2136
http://allmydata.org/trac/tahoe/changeset/2031

-------------- next part --------------
A non-text attachment was scrubbed...
Name: convertshares.py
Type: text/x-python-script
Size: 1992 bytes
Desc: not available
URL: <http://tahoe-lafs.org/pipermail/tahoe-dev/attachments/20080214/617bcea6/attachment.bin>
-------------- next part --------------

------- begin appended convertshares.py
#!/usr/bin/env python

import os

from allmydata.util import fileutil, idlib
from allmydata.storage import storage_index_to_dir

newtopdirs = set()
for sidir in os.listdir('.'):
     if idlib.could_be_base32_encoded_l(sidir, 128):
         newtopdir = idlib.b2a_l(idlib.a2b(sidir)[:2], 14)
         if not newtopdir in newtopdirs:
             newtopdirs.add(newtopdir)
             fileutil.make_dirs(newtopdir)
         try:
             os.rename(sidir, os.path.join(newtopdir, sidir))
         except EnvironmentError:
             # Maybe there is already a sidir there and we need to  
move the
             # contents of this sidir into it.
             for fn in os.listdir(sidir):
                 os.rename(os.path.join(sidir, fn), os.path.join 
(newtopdir, sidir, fn))
             # Okay, good, now rmdir the old one.
             os.rmdir(sidir)


newnewtopdirs = set()
for dirpath, dirnames, filenames in os.walk('.'):
     for dirname in dirnames:
         if idlib.could_be_base32_encoded_l(dirname, 128):
             si = idlib.a2b_l(dirname, 128)
             sidir = storage_index_to_dir(si)
             topdir = os.path.dirname(sidir)
             if not topdir in newnewtopdirs:
                 newnewtopdirs.add(topdir)
                 fileutil.make_dirs(topdir)
             try:
                 os.rename(os.path.join(dirpath, dirname), sidir)
             except EnvironmentError:
                 # Maybe there is already a sidir there and we need  
to move the
                 # contents of this sidir into it.
                 for fn in os.listdir(os.path.join(dirpath, dirname)):
                     os.rename(os.path.join(dirpath, dirname, fn),  
os.path.join(sidir, fn))
                 # Okay, good, now rmdir the old one.
                 os.rmdir(os.path.join(dirpath, dirname))
     try:
         os.rmdir(dirpath)
     except EnvironmentError:
         pass

for oldnewtopdir in newtopdirs:
     try:
         os.rmdir(oldnewtopdir)
     except EnvironmentError:
         pass



More information about the tahoe-dev mailing list