put is upsert for files
This commit is contained in:
@@ -268,11 +268,7 @@ func (server *Server) apiV0FilesIDPutHandler(w http.ResponseWriter, r *http.Requ
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
branch, ok := branches[id]
|
||||
if !ok {
|
||||
http.NotFound(w, r)
|
||||
return nil
|
||||
}
|
||||
branch, _ := branches[id]
|
||||
branch.Updated = time.Now().UTC()
|
||||
if title := r.Header.Get("Title"); title != "" {
|
||||
branch.Title = title
|
||||
@@ -284,7 +280,14 @@ func (server *Server) apiV0FilesIDPutHandler(w http.ResponseWriter, r *http.Requ
|
||||
if err := server.putContentHandler(server.diskFilePath(id), w, r); err != nil {
|
||||
return err
|
||||
}
|
||||
return tree.Put(id, branch)
|
||||
if err := tree.Put(id, branch); err != nil {
|
||||
return err
|
||||
}
|
||||
return json.NewEncoder(w).Encode(map[string]map[string]string{
|
||||
"data": map[string]string{
|
||||
"filePath": path.Join("/api/v0/files", id),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (server *Server) apiV0FilesIDGetHandler(w http.ResponseWriter, r *http.Request) error {
|
||||
|
||||
Reference in New Issue
Block a user