forked from AlistGo/alist
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.go
More file actions
55 lines (51 loc) · 1.14 KB
/
dev.go
File metadata and controls
55 lines (51 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package data
import (
"context"
"github.com/alist-org/alist/v3/cmd/flags"
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/message"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/op"
log "github.com/sirupsen/logrus"
)
func initDevData() {
_, err := op.CreateStorage(context.Background(), model.Storage{
MountPath: "/",
Order: 0,
Driver: "Local",
Status: "",
Addition: `{"root_folder_path":"."}`,
})
if err != nil {
log.Fatalf("failed to create storage: %+v", err)
}
err = db.CreateUser(&model.User{
Username: "Noah",
Password: "hsu",
BasePath: "/data",
Role: nil,
Permission: 512,
})
if err != nil {
log.Fatalf("failed to create user: %+v", err)
}
}
func initDevDo() {
if flags.Dev {
go func() {
err := message.GetMessenger().WaitSend(message.Message{
Type: "string",
Content: "dev mode",
}, 10)
if err != nil {
log.Debugf("%+v", err)
}
m, err := message.GetMessenger().WaitReceive(10)
if err != nil {
log.Debugf("%+v", err)
} else {
log.Debugf("received: %+v", m)
}
}()
}
}