修改根路径位置
This commit is contained in:
parent
5aa6dfbec6
commit
d84b5fe777
19
cmd/app.go
19
cmd/app.go
@ -13,8 +13,17 @@ import (
|
|||||||
"github.com/filebrowser/filebrowser/v2/service"
|
"github.com/filebrowser/filebrowser/v2/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if os.Getenv("MODE_ENV") != "" {
|
||||||
|
os.Setenv(constant.ConfigFileEnvKey, fmt.Sprintf("./conf/%s/%s", os.Getenv("MODE_ENV"), "dubbogo.yaml"))
|
||||||
|
service.BasePath = "./data"
|
||||||
|
} else {
|
||||||
|
os.Setenv(constant.ConfigFileEnvKey, "../conf/dubbogo.yaml")
|
||||||
|
service.BasePath = "../"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
initEnv()
|
|
||||||
config.SetProviderService(&service.FilesProvider{})
|
config.SetProviderService(&service.FilesProvider{})
|
||||||
if err := config.Load(); err != nil {
|
if err := config.Load(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -25,11 +34,3 @@ func main() {
|
|||||||
log.Printf("Caught signal %s: shutting down.", sig)
|
log.Printf("Caught signal %s: shutting down.", sig)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initEnv() {
|
|
||||||
if os.Getenv("MODE_ENV") != "" {
|
|
||||||
os.Setenv(constant.ConfigFileEnvKey, fmt.Sprintf("./conf/%s/%s", os.Getenv("MODE_ENV"), "dubbogo.yaml"))
|
|
||||||
} else {
|
|
||||||
os.Setenv(constant.ConfigFileEnvKey, "../conf/dubbogo.yaml")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -31,7 +31,7 @@ type FilesProvider struct {
|
|||||||
filesApi.UnimplementedFileServer
|
filesApi.UnimplementedFileServer
|
||||||
}
|
}
|
||||||
|
|
||||||
const BASE_PATH = "../"
|
var BasePath = "../"
|
||||||
|
|
||||||
var imgSvc = img.New(4) // 图片预览可用协程数
|
var imgSvc = img.New(4) // 图片预览可用协程数
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ func newFileDownloadWriter(stream filesApi.File_DirDownloadServer) *fileDownload
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getFs(userSpacePath string) afero.Fs {
|
func getFs(userSpacePath string) afero.Fs {
|
||||||
bashAbs, _ := filepath.Abs(BASE_PATH)
|
bashAbs, _ := filepath.Abs(BasePath)
|
||||||
|
|
||||||
if !strings.HasPrefix(userSpacePath, "/") {
|
if !strings.HasPrefix(userSpacePath, "/") {
|
||||||
userSpacePath = "/" + userSpacePath
|
userSpacePath = "/" + userSpacePath
|
||||||
|
Loading…
Reference in New Issue
Block a user