Skip to content

Commit a4423ab

Browse files
author
JojiiOfficial
committed
implement delete namespace
1 parent 6e4cc0a commit a4423ab

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

dmfs/dmfsRoot.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log"
77
"syscall"
8+
"time"
89

910
"github.com/DataManager-Go/libdatamanager"
1011
dmConfig "github.com/DataManager-Go/libdatamanager/config"
@@ -76,8 +77,20 @@ func (root *dmanagerRoot) OnAdd(ctx context.Context) {
7677
// Unlink if virtual file was unlinked
7778
func (root *dmanagerRoot) Rmdir(ctx context.Context, name string) syscall.Errno {
7879
namespace := addNSName(name, root.libdm.Config)
79-
// TODO delete namespace
80-
fmt.Println("rm", namespace)
80+
81+
// wait 2 seconds to ensure, user didn't cancel
82+
select {
83+
case <-ctx.Done():
84+
return syscall.ECANCELED
85+
case <-time.After(2 * time.Second):
86+
}
87+
88+
// Do delete request
89+
if _, err := root.libdm.DeleteNamespace(namespace); err != nil {
90+
fmt.Println(err)
91+
return syscall.EFAULT
92+
}
93+
8194
return 0
8295
}
8396

0 commit comments

Comments
 (0)