aboutsummaryrefslogtreecommitdiff
path: root/pkg/driver/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/driver/utils.go')
-rw-r--r--pkg/driver/utils.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/pkg/driver/utils.go b/pkg/driver/utils.go
index 485d4da..b629543 100644
--- a/pkg/driver/utils.go
+++ b/pkg/driver/utils.go
@@ -3,6 +3,7 @@ package driver
import (
"fmt"
"os"
+ "path/filepath"
"strings"
"sync"
@@ -14,6 +15,10 @@ import (
)
func NewNodeServer(n *SeaweedFsDriver) *NodeServer {
+ if err := removeDirContent(n.CacheDir); err != nil {
+ glog.Warning("error cleaning up cache dir")
+ }
+
return &NodeServer{
Driver: n,
volumeMutexes: NewKeyMutex(),
@@ -83,6 +88,22 @@ func checkMount(targetPath string) (bool, error) {
return notMnt, nil
}
+func removeDirContent(path string) error {
+ files, err := filepath.Glob(filepath.Join(path, "*"))
+ if err != nil {
+ return err
+ }
+
+ for _, file := range files {
+ err = os.RemoveAll(file)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
type KeyMutex struct {
mutexes sync.Map
}