mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-15 00:34:52 +08:00
Add option to recursively delete a folder.
This commit is contained in:
@@ -21,7 +21,7 @@ func NewFilerServer(r *http.ServeMux, port int, master string, dir string, colle
|
||||
port: ":" + strconv.Itoa(port),
|
||||
}
|
||||
|
||||
if fs.filer, err = filer.NewFilerEmbedded(dir); err != nil {
|
||||
if fs.filer, err = filer.NewFilerEmbedded(master, dir); err != nil {
|
||||
glog.Fatal("Can not start filer in dir", dir, ": ", err.Error())
|
||||
return
|
||||
}
|
||||
|
@@ -171,11 +171,14 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// curl -X DELETE http://localhost:8888/path/to
|
||||
// curl -X DELETE http://localhost:8888/path/to?recursive=true
|
||||
func (fs *FilerServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var err error
|
||||
var fid string
|
||||
if strings.HasSuffix(r.URL.Path, "/") {
|
||||
err = fs.filer.DeleteDirectory(r.URL.Path)
|
||||
isRecursive := r.FormValue("recursive") == "true"
|
||||
err = fs.filer.DeleteDirectory(r.URL.Path, isRecursive)
|
||||
} else {
|
||||
fid, err = fs.filer.DeleteFile(r.URL.Path)
|
||||
if err == nil {
|
||||
|
Reference in New Issue
Block a user