Commit 8fd9d48c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6d86fb8e
...@@ -23,10 +23,11 @@ ...@@ -23,10 +23,11 @@
XXX doc XXX doc
""" """
import os, sys, hashlib, tempfile, subprocess, errno, time import os, sys, hashlib, tempfile, subprocess, time
import logging as log import logging as log
from os.path import dirname from os.path import dirname
from golang import go, chan, select, default from golang import go, chan, select, default
from errno import ENOENT, EEXIST
from ZODB.FileStorage import FileStorage from ZODB.FileStorage import FileStorage
...@@ -61,7 +62,7 @@ def serve(zurl, exec_=False): ...@@ -61,7 +62,7 @@ def serve(zurl, exec_=False):
try: try:
f = open(mntpt + "/.wcfs") f = open(mntpt + "/.wcfs")
except IOError as e: except IOError as e:
if e.errno != errno.ENOENT: if e.errno != ENOENT:
raise raise
else: else:
f.close() f.close()
...@@ -91,7 +92,7 @@ def join(zurl, autostart=None): ...@@ -91,7 +92,7 @@ def join(zurl, autostart=None):
try: try:
f = open(mntpt + "/.wcfs") f = open(mntpt + "/.wcfs")
except IOError as e: except IOError as e:
if e.errno != errno.ENOENT: if e.errno != ENOENT:
raise raise
else: else:
# already have it # already have it
...@@ -156,7 +157,7 @@ def _start(zurl): ...@@ -156,7 +157,7 @@ def _start(zurl):
try: try:
f = open("%s/.wcfs" % mntpt) f = open("%s/.wcfs" % mntpt)
except IOError as e: except IOError as e:
if e.errno != errno.ENOENT: if e.errno != ENOENT:
raise raise
else: else:
res = f res = f
...@@ -216,12 +217,24 @@ def _wcfs_exe(): ...@@ -216,12 +217,24 @@ def _wcfs_exe():
return '%s/wcfs' % dirname(__file__) return '%s/wcfs' % dirname(__file__)
# _mntpt_4zurl returns wcfs should-be mountpoint for ZODB @ zurl. # _mntpt_4zurl returns wcfs should-be mountpoint for ZODB @ zurl.
#
# it also makes sure the mountpoint exists.
def _mntpt_4zurl(zurl): def _mntpt_4zurl(zurl):
# XXX stub.
# XXX what is zurl is zconfig://... ? -> then we have to look inside? # XXX what is zurl is zconfig://... ? -> then we have to look inside?
m = hashlib.sha1() m = hashlib.sha1()
m.update(zurl) m.update(zurl)
return "%s/wcfs/%s" % (tempfile.gettempdir(), m.hexdigest()) mntpt = "%s/wcfs/%s" % (tempfile.gettempdir(), m.hexdigest())
_mkdir_p(mntpt)
return mntpt
# mkdir -p
def _mkdir_p(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != EEXIST:
raise
# _zstor_2zurl converts a ZODB storage to URL to access it. # _zstor_2zurl converts a ZODB storage to URL to access it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment