1. root dir has id of 0

2. only delete empty folders
3. correct listing files under a folder
This commit is contained in:
Chris Lu
2014-04-09 21:01:48 -07:00
parent abde40377c
commit 5f4dc11409
5 changed files with 26 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
package filer
import (
"fmt"
"path/filepath"
)
@@ -52,6 +53,13 @@ func (filer *FilerEmbedded) ListFiles(dirPath string, lastFileName string, limit
return filer.files.ListFiles(dirId, lastFileName, limit), nil
}
func (filer *FilerEmbedded) DeleteDirectory(dirPath string) (err error) {
dirId, e := filer.directories.FindDirectory(dirPath)
if e != nil {
return e
}
if len(filer.files.ListFiles(dirId, "", 1)) > 0 {
return fmt.Errorf("Fail to delete non-empty directory %s!", dirPath)
}
return filer.directories.DeleteDirectory(dirPath)
}
func (filer *FilerEmbedded) DeleteFile(filePath string) (fid string, err error) {