From a974edc90df65f5344b87482b2d01ce2eb1579f6 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov <kirr@nexedi.com> Date: Tue, 25 Dec 2018 15:58:03 +0300 Subject: [PATCH] . --- wcfs/wcfs.go | 9 ++++++++- wcfs/wcfs_test.py | 17 +++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/wcfs/wcfs.go b/wcfs/wcfs.go index adb84b6..6ff90c9 100644 --- a/wcfs/wcfs.go +++ b/wcfs/wcfs.go @@ -789,12 +789,14 @@ func bigopen(ctx context.Context, zconn *ZConn, oid zodb.Oid) (_ *BigFile, err e zconn.Incref() return &BigFile{ + Node: nodefs.NewDefaultNode(), zconn: zconn, zbf: zbf, zbfSize: zbfSize, // XXX this is needed only for head/ δFtail: NewΔTailI64(), // XXX indicate we have coverage starting from zconn.at? + loading: make(map[int64]*blkLoadState), }, nil } @@ -1089,8 +1091,13 @@ func main() { // add entries to / mkfile(root, ".wcfs", NewStaticFile([]byte(zurl))) - mkdir(root, "head", &Head{ + head := &Head{ + Node: nodefs.NewDefaultNode(), + } + mkdir(root, "head", head) + mkdir(head, "bigfile", &BigFileDir{ Node: nodefs.NewDefaultNode(), + tab: make(map[zodb.Oid]*BigFile), }) // TODO handle autoexit diff --git a/wcfs/wcfs_test.py b/wcfs/wcfs_test.py index b97281c..aa84c21 100644 --- a/wcfs/wcfs_test.py +++ b/wcfs/wcfs_test.py @@ -99,7 +99,8 @@ def test_join(): defer(wc.close) assert wc.mountpoint == testmntpt assert readfile(wc.mountpoint + "/.wcfs") == zurl - assert os.path.isdir(wc.mountpoint + "/bigfile") + assert os.path.isdir(wc.mountpoint + "/head") + assert os.path.isdir(wc.mountpoint + "/head/bigfile") wc2 = wcfs.join(zurl, autostart=False) defer(wc2.close) @@ -115,7 +116,8 @@ def test_join_autostart(): defer(wc.close) assert wc.mountpoint == testmntpt assert readfile(wc.mountpoint + "/.wcfs") == zurl - assert os.path.isdir(wc.mountpoint + "/bigfile") + assert os.path.isdir(wc.mountpoint + "/head") + assert os.path.isdir(wc.mountpoint + "/head/bigfile") # XXX hack (tmp ?) @@ -163,20 +165,19 @@ def test_bigfile_empty(): wc = wcfs.join(testzurl, autostart=True) defer(wc.close) - # path to bigfile/ under wcfs - bigpath = wc.mountpoint + "/bigfile" + # path to head/bigfile/ under wcfs + bigpath = wc.mountpoint + "/head/bigfile" - # mkdir to non-BigFile - must be rejected + # lookup to non-BigFile - must be rejected with raises(OSError) as exc: - os.mkdir("%s/%s" % (bigpath, last._p_oid.encode('hex'))) + os.stat("%s/%s" % (bigpath, last._p_oid.encode('hex'))) assert exc.value.errno == EINVAL # path to f under wcfs fpath = "%s/%s" % (bigpath, f._p_oid.encode('hex')) - os.mkdir(fpath) - st = os.stat(fpath + "/head/data") + st = os.stat(fpath) assert st.st_size == 0 assert st.st_mtime == tidtime(tid1) -- 2.30.9