Skip to content

Commit f240d04

Browse files
authored
Merge pull request gusaul#36 from beruangcoklat/master
handle error when remove and create directory
2 parents c5b61eb + 6d348c6 commit f240d04

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

core/resource.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,14 @@ func (r *Resource) AddProtos(protos []Proto) error {
285285
protoPath := filepath.Join(BasePath, r.clientConn.Target())
286286
err := os.MkdirAll(protoPath, 0777)
287287
if os.IsExist(err) {
288-
os.RemoveAll(protoPath)
288+
err = os.RemoveAll(protoPath)
289+
if err != nil {
290+
return err
291+
}
289292
err = os.MkdirAll(protoPath, 0777)
293+
if err != nil {
294+
return err
295+
}
290296
} else if err != nil {
291297
return err
292298
}

core/resource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func Test_prepareImport(t *testing.T) {
6060
}
6161
for _, tt := range tests {
6262
t.Run(tt.name, func(t *testing.T) {
63-
if got := prepareImport(tt.args.proto, ""); !reflect.DeepEqual(got, tt.want) {
63+
if got := prepareImport(tt.args.proto); !reflect.DeepEqual(got, tt.want) {
6464
t.Errorf("prepareImport() = %v, want %v",
6565
string(got),
6666
string(tt.want))

0 commit comments

Comments
 (0)