Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
b078915f
Commit
b078915f
authored
Jan 12, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add context to files reading
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
b4a47e35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
core/commands/files/files.go
core/commands/files/files.go
+14
-1
No files found.
core/commands/files/files.go
View file @
b078915f
...
...
@@ -374,7 +374,7 @@ Examples:
res.SetError(err, cmds.ErrNormal)
return
}
var r io.Reader =
fi
var r io.Reader =
&contextReaderWrapper{R: fi, ctx: req.Context()}
count, found, err := req.Option("count").Int()
if err != nil {
res.SetError(err, cmds.ErrNormal)
...
...
@@ -392,6 +392,19 @@ Examples:
},
}
type contextReader interface {
CtxReadFull(context.Context, []byte) (int, error)
}
type contextReaderWrapper struct {
R contextReader
ctx context.Context
}
func (crw *contextReaderWrapper) Read(b []byte) (int, error) {
return crw.R.CtxReadFull(crw.ctx, b)
}
var FilesMvCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Move files.",
...
...
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