main: update webdav with context

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2018-04-03 20:32:27 -04:00
parent a06aa900b7
commit 83a1e114b0
Signed by: vbatts
GPG Key ID: 10937E57733F1362
1 changed files with 6 additions and 5 deletions

11
main.go
View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"context"
"flag" "flag"
"fmt" "fmt"
"log" "log"
@ -85,23 +86,23 @@ type passThroughFS struct {
root string root string
} }
func (ptfs *passThroughFS) Mkdir(name string, perm os.FileMode) error { func (ptfs *passThroughFS) Mkdir(ctx context.Context, name string, perm os.FileMode) error {
// TODO(vbatts) check for escaping the root directory // TODO(vbatts) check for escaping the root directory
return os.Mkdir(filepath.Join(ptfs.root, name), perm) return os.Mkdir(filepath.Join(ptfs.root, name), perm)
} }
func (ptfs *passThroughFS) OpenFile(name string, flag int, perm os.FileMode) (webdav.File, error) { func (ptfs *passThroughFS) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error) {
// TODO(vbatts) check for escaping the root directory // TODO(vbatts) check for escaping the root directory
return os.OpenFile(filepath.Join(ptfs.root, name), flag, perm) return os.OpenFile(filepath.Join(ptfs.root, name), flag, perm)
} }
func (ptfs *passThroughFS) RemoveAll(name string) error { func (ptfs *passThroughFS) RemoveAll(ctx context.Context, name string) error {
// TODO(vbatts) check for escaping the root directory // TODO(vbatts) check for escaping the root directory
return os.RemoveAll(filepath.Join(ptfs.root, name)) return os.RemoveAll(filepath.Join(ptfs.root, name))
} }
func (ptfs *passThroughFS) Rename(oldName, newName string) error { func (ptfs *passThroughFS) Rename(ctx context.Context, oldName, newName string) error {
// TODO(vbatts) check for escaping the root directory // TODO(vbatts) check for escaping the root directory
return os.Rename(filepath.Join(ptfs.root, oldName), filepath.Join(ptfs.root, newName)) return os.Rename(filepath.Join(ptfs.root, oldName), filepath.Join(ptfs.root, newName))
} }
func (ptfs *passThroughFS) Stat(name string) (os.FileInfo, error) { func (ptfs *passThroughFS) Stat(ctx context.Context, name string) (os.FileInfo, error) {
// TODO(vbatts) check for escaping the root directory // TODO(vbatts) check for escaping the root directory
return os.Stat(filepath.Join(ptfs.root, name)) return os.Stat(filepath.Join(ptfs.root, name))
} }