Skip to content

Commit

Permalink
Merge pull request mattn#2 from bcho/fix/context
Browse files Browse the repository at this point in the history
update FileSystem signature with context
  • Loading branch information
mattn committed Apr 19, 2017
2 parents b3e938f + 09a4a23 commit 6226fb0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
11 changes: 6 additions & 5 deletions plugin/mysql/mysql.go
Expand Up @@ -13,6 +13,7 @@ import (

_ "github.com/go-sql-driver/mysql"
"github.com/mattn/davfs"
"golang.org/x/net/context"
"golang.org/x/net/webdav"
)

Expand Down Expand Up @@ -101,7 +102,7 @@ func clearName(name string) (string, error) {
return name, nil
}

func (fs *FileSystem) Mkdir(name string, perm os.FileMode) error {
func (fs *FileSystem) Mkdir(ctx context.Context, name string, perm os.FileMode) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -138,7 +139,7 @@ func (fs *FileSystem) Mkdir(name string, perm os.FileMode) error {
return nil
}

func (fs *FileSystem) OpenFile(name string, flag int, perm os.FileMode) (webdav.File, error) {
func (fs *FileSystem) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error) {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -205,7 +206,7 @@ func (fs *FileSystem) removeAll(name string) error {
return err
}

func (fs *FileSystem) RemoveAll(name string) error {
func (fs *FileSystem) RemoveAll(ctx context.Context, name string) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand All @@ -216,7 +217,7 @@ func (fs *FileSystem) RemoveAll(name string) error {
return fs.removeAll(name)
}

func (fs *FileSystem) Rename(oldName, newName string) error {
func (fs *FileSystem) Rename(ctx context.Context, oldName, newName string) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -288,7 +289,7 @@ func (fs *FileSystem) stat(name string) (os.FileInfo, error) {
return &fi, nil
}

func (fs *FileSystem) Stat(name string) (os.FileInfo, error) {
func (fs *FileSystem) Stat(ctx context.Context, name string) (os.FileInfo, error) {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down
13 changes: 7 additions & 6 deletions plugin/postgres/postgres.go
Expand Up @@ -13,12 +13,13 @@ import (

_ "github.com/lib/pq"
"github.com/mattn/davfs"
"golang.org/x/net/context"
"golang.org/x/net/webdav"
)

const createSQL = `
create table filesystem(
name text not null,
name text not null,
content text not null,
mode bigint not null,
mod_time timestamp not null,
Expand Down Expand Up @@ -88,7 +89,7 @@ func clearName(name string) (string, error) {
return name, nil
}

func (fs *FileSystem) Mkdir(name string, perm os.FileMode) error {
func (fs *FileSystem) Mkdir(ctx context.Context, name string, perm os.FileMode) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -125,7 +126,7 @@ func (fs *FileSystem) Mkdir(name string, perm os.FileMode) error {
return nil
}

func (fs *FileSystem) OpenFile(name string, flag int, perm os.FileMode) (webdav.File, error) {
func (fs *FileSystem) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error) {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -192,7 +193,7 @@ func (fs *FileSystem) removeAll(name string) error {
return err
}

func (fs *FileSystem) RemoveAll(name string) error {
func (fs *FileSystem) RemoveAll(ctx context.Context, name string) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand All @@ -203,7 +204,7 @@ func (fs *FileSystem) RemoveAll(name string) error {
return fs.removeAll(name)
}

func (fs *FileSystem) Rename(oldName, newName string) error {
func (fs *FileSystem) Rename(ctx context.Context, oldName, newName string) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -275,7 +276,7 @@ func (fs *FileSystem) stat(name string) (os.FileInfo, error) {
return &fi, nil
}

func (fs *FileSystem) Stat(name string) (os.FileInfo, error) {
func (fs *FileSystem) Stat(ctx context.Context, name string) (os.FileInfo, error) {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down
13 changes: 7 additions & 6 deletions plugin/sqlite3/sqlite3.go
Expand Up @@ -13,12 +13,13 @@ import (

"github.com/mattn/davfs"
_ "github.com/mattn/go-sqlite3"
"golang.org/x/net/context"
"golang.org/x/net/webdav"
)

const createSQL = `
create table filesystem(
name text not null,
name text not null,
content text not null,
mode bigint not null,
mod_time timestamp not null,
Expand Down Expand Up @@ -88,7 +89,7 @@ func clearName(name string) (string, error) {
return name, nil
}

func (fs *FileSystem) Mkdir(name string, perm os.FileMode) error {
func (fs *FileSystem) Mkdir(ctx context.Context, name string, perm os.FileMode) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -125,7 +126,7 @@ func (fs *FileSystem) Mkdir(name string, perm os.FileMode) error {
return nil
}

func (fs *FileSystem) OpenFile(name string, flag int, perm os.FileMode) (webdav.File, error) {
func (fs *FileSystem) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error) {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -192,7 +193,7 @@ func (fs *FileSystem) removeAll(name string) error {
return err
}

func (fs *FileSystem) RemoveAll(name string) error {
func (fs *FileSystem) RemoveAll(ctx context.Context, name string) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand All @@ -203,7 +204,7 @@ func (fs *FileSystem) RemoveAll(name string) error {
return fs.removeAll(name)
}

func (fs *FileSystem) Rename(oldName, newName string) error {
func (fs *FileSystem) Rename(ctx context.Context, oldName, newName string) error {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down Expand Up @@ -274,7 +275,7 @@ func (fs *FileSystem) stat(name string) (os.FileInfo, error) {
return &fi, nil
}

func (fs *FileSystem) Stat(name string) (os.FileInfo, error) {
func (fs *FileSystem) Stat(ctx context.Context, name string) (os.FileInfo, error) {
fs.mu.Lock()
defer fs.mu.Unlock()

Expand Down

0 comments on commit 6226fb0

Please sign in to comment.