projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adds 'awscli' package to the salt installer state for encrypted ssl privkeys.
[arvados.git]
/
services
/
keep-web
/
webdav.go
diff --git
a/services/keep-web/webdav.go
b/services/keep-web/webdav.go
index 5b23c9c5fa9f10bffec55d48e6950fd0ac76d639..0039f04eeff369a5fb5de3132389762d16535161 100644
(file)
--- a/
services/keep-web/webdav.go
+++ b/
services/keep-web/webdav.go
@@
-2,7
+2,7
@@
//
// SPDX-License-Identifier: AGPL-3.0
//
// SPDX-License-Identifier: AGPL-3.0
-package
main
+package
keepweb
import (
"crypto/rand"
import (
"crypto/rand"
@@
-16,7
+16,7
@@
import (
"sync/atomic"
"time"
"sync/atomic"
"time"
- "git.
curoverse.com
/arvados.git/sdk/go/arvados"
+ "git.
arvados.org
/arvados.git/sdk/go/arvados"
"golang.org/x/net/context"
"golang.org/x/net/webdav"
"golang.org/x/net/context"
"golang.org/x/net/webdav"
@@
-36,7
+36,10
@@
var (
// existence automatically so sequences like "mkcol foo; put foo/bar"
// work as expected.
type webdavFS struct {
// existence automatically so sequences like "mkcol foo; put foo/bar"
// work as expected.
type webdavFS struct {
- collfs arvados.FileSystem
+ collfs arvados.FileSystem
+ // prefix works like fs.Sub: Stat(name) calls
+ // Stat(prefix+name) in the wrapped filesystem.
+ prefix string
writing bool
// webdav PROPFIND reads the first few bytes of each file
// whose filename extension isn't recognized, which is
writing bool
// webdav PROPFIND reads the first few bytes of each file
// whose filename extension isn't recognized, which is
@@
-56,7
+59,7
@@
func (fs *webdavFS) makeparents(name string) {
}
dir = dir[:len(dir)-1]
fs.makeparents(dir)
}
dir = dir[:len(dir)-1]
fs.makeparents(dir)
- fs.collfs.Mkdir(dir, 0755)
+ fs.collfs.Mkdir(
fs.prefix+
dir, 0755)
}
func (fs *webdavFS) Mkdir(ctx context.Context, name string, perm os.FileMode) error {
}
func (fs *webdavFS) Mkdir(ctx context.Context, name string, perm os.FileMode) error {
@@
-65,7
+68,7
@@
func (fs *webdavFS) Mkdir(ctx context.Context, name string, perm os.FileMode) er
}
name = strings.TrimRight(name, "/")
fs.makeparents(name)
}
name = strings.TrimRight(name, "/")
fs.makeparents(name)
- return fs.collfs.Mkdir(name, 0755)
+ return fs.collfs.Mkdir(
fs.prefix+
name, 0755)
}
func (fs *webdavFS) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (f webdav.File, err error) {
}
func (fs *webdavFS) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (f webdav.File, err error) {
@@
-73,7
+76,7
@@
func (fs *webdavFS) OpenFile(ctx context.Context, name string, flag int, perm os
if writing {
fs.makeparents(name)
}
if writing {
fs.makeparents(name)
}
- f, err = fs.collfs.OpenFile(name, flag, perm)
+ f, err = fs.collfs.OpenFile(
fs.prefix+
name, flag, perm)
if !fs.writing {
// webdav module returns 404 on all OpenFile errors,
// but returns 405 Method Not Allowed if OpenFile()
if !fs.writing {
// webdav module returns 404 on all OpenFile errors,
// but returns 405 Method Not Allowed if OpenFile()
@@
-93,22
+96,27
@@
func (fs *webdavFS) OpenFile(ctx context.Context, name string, flag int, perm os
}
func (fs *webdavFS) RemoveAll(ctx context.Context, name string) error {
}
func (fs *webdavFS) RemoveAll(ctx context.Context, name string) error {
- return fs.collfs.RemoveAll(name)
+ return fs.collfs.RemoveAll(
fs.prefix +
name)
}
func (fs *webdavFS) Rename(ctx context.Context, oldName, newName string) error {
if !fs.writing {
return errReadOnly
}
}
func (fs *webdavFS) Rename(ctx context.Context, oldName, newName string) error {
if !fs.writing {
return errReadOnly
}
+ if strings.HasSuffix(oldName, "/") {
+ // WebDAV "MOVE foo/ bar/" means rename foo to bar.
+ oldName = oldName[:len(oldName)-1]
+ newName = strings.TrimSuffix(newName, "/")
+ }
fs.makeparents(newName)
fs.makeparents(newName)
- return fs.collfs.Rename(
oldName,
newName)
+ return fs.collfs.Rename(
fs.prefix+oldName, fs.prefix+
newName)
}
func (fs *webdavFS) Stat(ctx context.Context, name string) (os.FileInfo, error) {
if fs.writing {
fs.makeparents(name)
}
}
func (fs *webdavFS) Stat(ctx context.Context, name string) (os.FileInfo, error) {
if fs.writing {
fs.makeparents(name)
}
- return fs.collfs.Stat(name)
+ return fs.collfs.Stat(
fs.prefix +
name)
}
type writeFailer struct {
}
type writeFailer struct {