Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
e7b5eab2
Commit
e7b5eab2
authored
Jul 17, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
aeb11950
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
11 deletions
+16
-11
wcfs/__init__.py
wcfs/__init__.py
+12
-7
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+4
-4
No files found.
wcfs/__init__.py
View file @
e7b5eab2
...
...
@@ -46,7 +46,7 @@ import threading
from
persistent
import
Persistent
from
ZODB.FileStorage
import
FileStorage
from
ZODB.utils
import
z64
,
u64
,
p64
from
zodbtools.util
import
ashex
,
fromhex
from
zodbtools.util
import
ashex
as
h
,
fromhex
from
.internal
import
mm
...
...
@@ -193,13 +193,18 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping
f
=
_File
()
f
.
wconn
=
wconn
f
.
foid
=
foid
f
.
headf
=
wconn
.
_wc
.
_open
(
"head/bigfile/%s"
%
(
ashex
(
foid
),),
"rb"
)
f
.
headf
=
wconn
.
_wc
.
_open
(
"head/bigfile/%s"
%
(
h
(
foid
),),
"rb"
)
f
.
blksize
=
os
.
fstat
(
f
.
headf
.
fileno
()).
st_blksize
f
.
pinned
=
{}
f
.
mmaps
=
[]
wconn
.
_filetab
[
foid
]
=
f
# XXX start watching f
# start watching f
_
=
wconn
.
_wlink
.
sendReq
(
context
.
background
(),
b"watch %s @%s"
%
(
h
(
foid
),
h
(
wconn
.
at
)))
if
_
!=
"ok"
:
# XXX unregister f from _filetab
# XXX vvv -> errctx?
raise
RuntimeError
(
"mmap f<%s>[%d +%d): %s"
%
(
h
(
foid
),
blk_start
,
blk_len
,
_
))
# XXX relock wconn -> f ?
...
...
@@ -231,7 +236,7 @@ def _remmapblk(mmap, blk, at):
fsfile
=
f
.
headf
else
:
# TODO share @rev fd until wconn is resynced?
fsfile
=
f
.
wconn
.
_wc
.
_open
(
"@%s/bigfile/%s"
%
(
ashex
(
at
),
ashex
(
f
.
foid
)),
"rb"
)
fsfile
=
f
.
wconn
.
_wc
.
_open
(
"@%s/bigfile/%s"
%
(
h
(
at
),
h
(
f
.
foid
)),
"rb"
)
defer
(
fsfile
.
close
)
assert
os
.
fstat
(
fsfile
.
fileno
()).
st_blksize
==
f
.
blksize
# FIXME assert
...
...
@@ -515,8 +520,8 @@ def _path(wc, obj, at=None):
#assert type(obj) is ZBigFile XXX import cycle
objtypestr
=
type
(
obj
).
__module__
+
"."
+
type
(
obj
).
__name__
assert
objtypestr
==
"wendelin.bigfile.file_zodb.ZBigFile"
,
objtypestr
head
=
"head/"
if
at
is
None
else
(
"@%s/"
%
ashex
(
at
))
obj
=
"%s/bigfile/%s"
%
(
head
,
ashex
(
obj
.
_p_oid
))
head
=
"head/"
if
at
is
None
else
(
"@%s/"
%
h
(
at
))
obj
=
"%s/bigfile/%s"
%
(
head
,
h
(
obj
.
_p_oid
))
at
=
None
assert
isinstance
(
obj
,
str
)
assert
at
is
None
# must not be used with str
...
...
@@ -558,7 +563,7 @@ def _open(wc, obj, mode='rb', at=None):
zat = p64(u64(zconn._storage._start)-1) # before -> at
# XXX pinned to @revX/... for now -> TODO /head/bigfile/...
path = '%s/@%s/bigfile/%s' % (self.mountpoint,
ashex(zat), ashex
(zfile._p_oid))
path = '%s/@%s/bigfile/%s' % (self.mountpoint,
h(zat), h
(zfile._p_oid))
fd = os.open(path, os.O_RDONLY)
return FileH(fd)
...
...
wcfs/wcfs_test.py
View file @
e7b5eab2
...
...
@@ -1736,16 +1736,16 @@ def test_wcfspy_virtmem():
assert
len
(
m1
.
mem
)
==
3
*
zf
.
blksize
f
=
m1
.
file
t1
=
tMapping
(
m1
)
t
m
1
=
tMapping
(
m1
)
#assertCache(m1, [0,0,0])
assert
f
.
pinned
==
{}
t1
.
assertBlk
(
2
,
'c1'
)
t
m
1
.
assertBlk
(
2
,
'c1'
)
assert
f
.
pinned
==
{
2
:
at1
}
t1
.
assertBlk
(
3
,
'd1'
)
t
m
1
.
assertBlk
(
3
,
'd1'
)
assert
f
.
pinned
==
{
2
:
at1
}
t1
.
assertBlk
(
3
,
'x'
)
t
m
1
.
assertBlk
(
3
,
'x'
)
assert
f
.
pinned
==
{
2
:
at1
}
#assertData (m1, ['c1','d1',''])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment