修改根路径位置

This commit is contained in:
lzh 2025-06-06 11:41:36 +08:00
parent 5aa6dfbec6
commit d84b5fe777
2 changed files with 12 additions and 11 deletions

View File

@ -13,8 +13,17 @@ import (
"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() {
initEnv()
config.SetProviderService(&service.FilesProvider{})
if err := config.Load(); err != nil {
panic(err)
@ -25,11 +34,3 @@ func main() {
log.Printf("Caught signal %s: shutting down.", sig)
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")
}
}

View File

@ -31,7 +31,7 @@ type FilesProvider struct {
filesApi.UnimplementedFileServer
}
const BASE_PATH = "../"
var BasePath = "../"
var imgSvc = img.New(4) // 图片预览可用协程数
@ -459,7 +459,7 @@ func newFileDownloadWriter(stream filesApi.File_DirDownloadServer) *fileDownload
}
func getFs(userSpacePath string) afero.Fs {
bashAbs, _ := filepath.Abs(BASE_PATH)
bashAbs, _ := filepath.Abs(BasePath)
if !strings.HasPrefix(userSpacePath, "/") {
userSpacePath = "/" + userSpacePath