Skip to content

Commit 8a28d3c

Browse files
committed
update create file and dir api
1 parent fb15695 commit 8a28d3c

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ gen
3030
/db/
3131
/docs/
3232
/conf/conf.ini
33+
__debug_bin

__debug_bin

-42.5 MB
Binary file not shown.

pkg/utils/oasis_err/e.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const (
1010
PWD_INVALID = 10001
1111

1212
//system
13-
DIR_ALREADY_EXISTS = 20001
13+
DIR_ALREADY_EXISTS = 20001
14+
FILE_ALREADY_EXISTS = 20002
15+
FILE_OR_DIR_EXISTS = 20003
1416

1517
//zerotier
1618
GET_TOKEN_ERROR = 30001
@@ -38,8 +40,9 @@ var MsgFlags = map[int]string{
3840
PWD_INVALID: "Password invalid",
3941

4042
//system
41-
DIR_ALREADY_EXISTS: "Directory already exists",
42-
43+
DIR_ALREADY_EXISTS: "Directory already exists",
44+
FILE_ALREADY_EXISTS: "File already exists",
45+
FILE_OR_DIR_EXISTS: "File or directory already exists",
4346

4447
//zerotier
4548
GET_TOKEN_ERROR: "Get token error,Please log in to zerotier's official website to confirm whether the account is available",

service/zima_info.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ func (c *zima) GetDirPath(path string) []model.Path {
8686

8787
if strings.Count(path, "/") > 1 {
8888
for _, l := range ls {
89-
dirs = append(dirs, model.Path{Name: l.Name(), Path: path + l.Name() + "/", IsDir: l.IsDir()})
89+
pathTemp := path + l.Name()
90+
if l.IsDir() {
91+
pathTemp += "/"
92+
}
93+
94+
dirs = append(dirs, model.Path{Name: l.Name(), Path: pathTemp, IsDir: l.IsDir()})
9095
}
9196
} else {
9297
dirs = append(dirs, model.Path{Name: "DATA", Path: "/DATA/", IsDir: true})
@@ -131,6 +136,8 @@ func (c *zima) MkdirAll(path string) (int, error) {
131136
if os.IsNotExist(err) {
132137
os.MkdirAll(path, os.ModePerm)
133138
return oasis_err.SUCCESS, nil
139+
} else if strings.Contains(err.Error(), ": not a directory") {
140+
return oasis_err.FILE_OR_DIR_EXISTS, err
134141
}
135142
}
136143
return oasis_err.ERROR, err
@@ -140,7 +147,7 @@ func (c *zima) MkdirAll(path string) (int, error) {
140147
func (c *zima) CreateFile(path string) (int, error) {
141148
_, err := os.Stat(path)
142149
if err == nil {
143-
return oasis_err.DIR_ALREADY_EXISTS, nil
150+
return oasis_err.FILE_OR_DIR_EXISTS, nil
144151
} else {
145152
if os.IsNotExist(err) {
146153
file.CreateFile(path)

types/system.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
package types
22

3-
const CURRENTVERSION = "0.1.5"
4-
const BODY = `
5-
<li>Add CPU RAM Status with widget</li>
6-
<li>Add Disk Info with widget</li>
7-
<li>Enhance the Docker cli import experience and automatically fill in the folders that need to be mounted</li>
8-
<li>Realize automatic loading of widgets</li>
9-
<li>Fix display bugs when windows size less than 1024px</li>
10-
`
3+
const CURRENTVERSION = "0.1.6"
4+
const BODY = "<li>Add a file selector for app install.</li> <li>Fixed an issue with the app were it would disappear when the app was modified.</li>"

0 commit comments

Comments
 (0)