all repos — flounder @ 92225891d3ccf5a64c99b5e4e73da078c3ed81ed

A small site builder for the Gemini protocol

Add remove command
alex wennerberg alex@alexwennerberg.com
Fri, 26 Feb 2021 21:34:07 -0800
commit

92225891d3ccf5a64c99b5e4e73da078c3ed81ed

parent

cf1bc7f98c8988285623ff592f6ee14861c12afd

1 files changed, 13 insertions(+), 6 deletions(-)

jump to
M sftp.gosftp.go

@@ -79,14 +79,21 @@ // remove, rename, setstat? find out

fullpath := path.Join(c.FilesDirectory, filepath.Clean(request.Filepath)) userDir := getUserDirectory(conn.User) // NOTE -- not cross platform writePerms := strings.HasPrefix(fullpath, userDir) - switch request.Method { - case "Remove": - if writePerms { - os.Remove(fullpath) - } else { - return fmt.Errorf("Unauthorized") + var err error + if writePerms { + switch request.Method { + case "Remove": + err = os.Remove(fullpath) + case "Mkdir": + err = os.Mkdir(fullpath, 0755) + } + if err != nil { + return err } + } else { + return fmt.Errorf("Unauthorized") } + // Rename, Mkdir return nil }