🚧 native webdav write

This commit is contained in:
微凉
2021-12-05 16:09:39 +08:00
parent 9c5627a382
commit 7dfe48339c
5 changed files with 140 additions and 13 deletions

View File

@ -130,8 +130,19 @@ func (fs *FileSystem) Link(r *http.Request, rawPath string) (string, error) {
return link, err
}
func (fs *FileSystem) CreateDirectory(ctx context.Context, reqPath string) (interface{}, error) {
return nil, nil
func (fs *FileSystem) CreateDirectory(ctx context.Context, rawPath string) error {
rawPath = utils.ParsePath(rawPath)
if rawPath == "/" {
return ErrNotImplemented
}
if model.AccountsCount() > 1 && len(strings.Split(rawPath, "/")) < 2 {
return ErrNotImplemented
}
account, path_, driver, err := ParsePath(rawPath)
if err != nil {
return err
}
return driver.MakeDir(path_,account)
}
func (fs *FileSystem) Upload(ctx context.Context, r *http.Request, rawPath string) error {

View File

@ -281,7 +281,8 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request, fs *FileSyst
return http.StatusMethodNotAllowed, err
}
etag, err := findETag(ctx, fs, h.LockSystem, reqPath, nil)
_, fi := isPathExist(ctx, fs, reqPath)
etag, err := findETag(ctx, fs, h.LockSystem, reqPath, fi)
if err != nil {
return http.StatusInternalServerError, err
}
@ -311,7 +312,7 @@ func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request, fs *FileSy
// ctx = context.WithValue(ctx, fsctx.IgnoreDirectoryConflictCtx, true)
//}
}
if _, err := fs.CreateDirectory(ctx, reqPath); err != nil {
if err := fs.CreateDirectory(ctx, reqPath); err != nil {
return http.StatusConflict, err
}
return http.StatusCreated, nil