Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
21d2b817f4
4 changed files with 17 additions and 3 deletions
10
main.go
10
main.go
|
@ -5,6 +5,7 @@ import (
|
|||
"flag"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudreve/Cloudreve/v3/bootstrap"
|
||||
|
@ -67,6 +68,15 @@ func main() {
|
|||
|
||||
// 如果启用了Unix
|
||||
if conf.UnixConfig.Listen != "" {
|
||||
// delete socket file before listening
|
||||
if _, err := os.Stat(conf.UnixConfig.Listen); err == nil {
|
||||
if err = os.Remove(conf.UnixConfig.Listen); err != nil {
|
||||
util.Log().Error("删除 socket 文件错误, %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
api.TrustedPlatform = conf.UnixConfig.ProxyHeader
|
||||
util.Log().Info("开始监听 %s", conf.UnixConfig.Listen)
|
||||
if err := api.RunUnix(conf.UnixConfig.Listen); err != nil {
|
||||
util.Log().Error("无法监听[%s],%s", conf.UnixConfig.Listen, err)
|
||||
|
|
|
@ -35,7 +35,8 @@ type ssl struct {
|
|||
}
|
||||
|
||||
type unix struct {
|
||||
Listen string
|
||||
Listen string
|
||||
ProxyHeader string `validate:"required_with=Listen"`
|
||||
}
|
||||
|
||||
// slave 作为slave存储端配置
|
||||
|
|
|
@ -45,7 +45,8 @@ var SSLConfig = &ssl{
|
|||
}
|
||||
|
||||
var UnixConfig = &unix{
|
||||
Listen: "",
|
||||
Listen: "",
|
||||
ProxyHeader: "X-Forwarded-For",
|
||||
}
|
||||
|
||||
var OptionOverwrite = map[string]interface{}{}
|
||||
|
|
|
@ -10,7 +10,9 @@ import (
|
|||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
|
@ -381,7 +383,7 @@ func findContentType(ctx context.Context, fs *filesystem.FileSystem, ls LockSyst
|
|||
//// Rewind file.
|
||||
//_, err = f.Seek(0, os.SEEK_SET)
|
||||
//return ctype, err
|
||||
return "", nil
|
||||
return mime.TypeByExtension(filepath.Ext(name)), nil
|
||||
}
|
||||
|
||||
// ETager is an optional interface for the os.FileInfo objects
|
||||
|
|
Loading…
Add table
Reference in a new issue