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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
ac777ea5
Commit
ac777ea5
authored
Oct 02, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a52fa604
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
wcfs/__init__.py
wcfs/__init__.py
+1
-1
wcfs/misc.go
wcfs/misc.go
+21
-10
No files found.
wcfs/__init__.py
View file @
ac777ea5
...
@@ -120,7 +120,7 @@ def join(zurl, autostart=_default_autostart()):
...
@@ -120,7 +120,7 @@ def join(zurl, autostart=_default_autostart()):
raise
RuntimeError
(
"wcfs: join %s: server not started"
%
zurl
)
raise
RuntimeError
(
"wcfs: join %s: server not started"
%
zurl
)
# start wcfs with telling it to automatically exit when there is no client activity.
# start wcfs with telling it to automatically exit when there is no client activity.
return
_start
(
zurl
,
"-autoexit"
)
return
_start
(
zurl
,
"-autoexit"
,
'-d'
)
# _start starts wcfs server for ZODB @ zurl.
# _start starts wcfs server for ZODB @ zurl.
...
...
wcfs/misc.go
View file @
ac777ea5
...
@@ -38,31 +38,42 @@ func asctx(fctx *fuse.Context) context.Context {
...
@@ -38,31 +38,42 @@ func asctx(fctx *fuse.Context) context.Context {
return
context
.
Background
()
return
context
.
Background
()
}
}
// StaticFile is a Node for file with static data.
type
StaticFile
struct
{
// NewStaticFile creates nodefs.Node for file with static data.
func
NewStaticFile
(
data
[]
byte
)
*
SmallFile
{
return
NewSmallFile
(
func
()
[]
byte
{
return
data
})
}
// SmallFile is a nodefs.Node for file with dynamic, but always small, data.
type
SmallFile
struct
{
nodefs
.
Node
nodefs
.
Node
data
[]
byte
// readData gives whole file data
readData
func
()
[]
byte
}
}
func
NewS
taticFile
(
data
[]
byte
)
*
Static
File
{
func
NewS
mallFile
(
readData
func
()
[]
byte
)
*
Small
File
{
return
&
S
taticFile
{
Node
:
nodefs
.
NewDefaultNode
(),
data
:
d
ata
}
return
&
S
mallFile
{
Node
:
nodefs
.
NewDefaultNode
(),
readData
:
readD
ata
}
}
}
func
(
f
*
StaticFile
)
GetAttr
(
out
*
fuse
.
Attr
,
_
nodefs
.
File
,
_
*
fuse
.
Context
)
fuse
.
Status
{
func
(
f
*
SmallFile
)
GetAttr
(
out
*
fuse
.
Attr
,
_
nodefs
.
File
,
_
*
fuse
.
Context
)
fuse
.
Status
{
out
.
Size
=
uint64
(
len
(
f
.
data
))
data
:=
f
.
readData
()
out
.
Size
=
uint64
(
len
(
data
))
out
.
Mode
=
fuse
.
S_IFREG
|
0644
out
.
Mode
=
fuse
.
S_IFREG
|
0644
return
fuse
.
OK
return
fuse
.
OK
}
}
func
(
f
*
StaticFile
)
Read
(
_
nodefs
.
File
,
dest
[]
byte
,
off
int64
,
_
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
func
(
f
*
SmallFile
)
Read
(
_
nodefs
.
File
,
dest
[]
byte
,
off
int64
,
_
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
l
:=
int64
(
len
(
f
.
data
))
data
:=
f
.
readData
()
l
:=
int64
(
len
(
data
))
end
:=
off
+
l
end
:=
off
+
l
if
end
>
l
{
if
end
>
l
{
end
=
l
end
=
l
}
}
return
fuse
.
ReadResultData
(
f
.
data
[
off
:
end
]),
fuse
.
OK
return
fuse
.
ReadResultData
(
data
[
off
:
end
]),
fuse
.
OK
}
}
...
...
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