File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
"os"
12
12
"path/filepath"
13
13
"sort"
14
+ "strings"
14
15
"sync"
15
16
"syscall"
16
17
"time"
@@ -90,12 +91,36 @@ func (fs *root) Filecmd(r *Request) error {
90
91
file .name = r .Target
91
92
fs .files [r .Target ] = file
92
93
delete (fs .files , r .Filepath )
94
+
95
+ if file .IsDir () {
96
+ for path , file := range fs .files {
97
+ if strings .HasPrefix (path , r .Filepath + "/" ) {
98
+ file .name = r .Target + path [len (r .Filepath ):]
99
+ fs .files [r .Target + path [len (r .Filepath ):]] = file
100
+ delete (fs .files , path )
101
+ }
102
+ }
103
+ }
93
104
case "Rmdir" , "Remove" :
94
- _ , err := fs .fetch (filepath .Dir(r .Filepath ))
105
+ file , err := fs .fetch (filepath .Dir (r .Filepath ))
95
106
if err != nil {
96
107
return err
97
108
}
109
+
110
+ if file .IsDir () {
111
+ for path := range fs .files {
112
+ if strings .HasPrefix (path , r .Filepath + "/" ) {
113
+ return & os.PathError {
114
+ Op : "remove" ,
115
+ Path : r .Filepath + "/" ,
116
+ Err : fmt .Errorf ("directory is not empty" ),
117
+ }
118
+ }
119
+ }
120
+ }
121
+
98
122
delete (fs .files , r .Filepath )
123
+
99
124
case "Mkdir" :
100
125
_ , err := fs .fetch (filepath .Dir (r .Filepath ))
101
126
if err != nil {
You can’t perform that action at this time.
0 commit comments