18947: Refactor keep-web as arvados-server command.
[arvados.git] / services / keep-web / webdav.go
index 3e62b19bbe296f35a514543121d3b29111133db1..501c355a7388a53fe3b40fc3f082c63768665620 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-package main
+package keepweb
 
 import (
        "crypto/rand"
@@ -16,7 +16,7 @@ import (
        "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"
@@ -50,7 +50,7 @@ func (fs *webdavFS) makeparents(name string) {
        if !fs.writing {
                return
        }
-       dir, name := path.Split(name)
+       dir, _ := path.Split(name)
        if dir == "" || dir == "/" {
                return
        }
@@ -100,6 +100,11 @@ 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)
        return fs.collfs.Rename(oldName, newName)
 }