Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
changed the directory scheme. now create a directory for every first …
Browse files Browse the repository at this point in the history
…character of the bucket name. the file name will be bucket + key and "/" will be substituted with "__"
  • Loading branch information
BuzzTroll committed Jul 6, 2010
1 parent e2aca39 commit 919a0ab
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cumulus/cb/pycb/cbPosixBackend.py
Expand Up @@ -28,9 +28,6 @@ def __init__(self, installdir):
except:
pass

def hash_file(self, name):
return urllib.quote(name, '')

# The POST request operation adds an object to a bucket using HTML forms.
#
# Not implemented for now
Expand All @@ -48,15 +45,18 @@ def post_object():
#
def put_object(self, bucketName, objectName):
# first make the bucket directory if it does not exist
bdir = self.base_dir + "/" + bucketName
dir_name = bucketName[:1]
bdir = self.base_dir + "/" + dir_name

try:
os.mkdir(bdir)
except OSError, ose:
if ose.errno != 17:
raise

objectName = objectName.replace("/", "__")
(osf, x) = tempfile.mkstemp(dir=bdir, prefix=objectName)
fname = bucketName + "/" + objectName
fname = fname.replace("/", "__")
(osf, x) = tempfile.mkstemp(dir=bdir, prefix=fname)
os.close(osf)
data_key = x.strip()
obj = cbPosixData(data_key, "w+b")
Expand Down

0 comments on commit 919a0ab

Please sign in to comment.