Add HTTPFS implementation (#93)
This commit is contained in:
parent
1d769673ca
commit
47198b3bc6
18 changed files with 549 additions and 44 deletions
|
@ -18,7 +18,9 @@ const (
|
|||
func DefaultConfig() *Root {
|
||||
return &Root{
|
||||
HTTPGlobal: &HTTPGlobal{
|
||||
Port: 4444,
|
||||
Port: 4444,
|
||||
IP: "0.0.0.0",
|
||||
HTTPFS: true,
|
||||
},
|
||||
WebDAV: &WebDAVGlobal{
|
||||
Port: 36911,
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/goccy/go-yaml"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestTemplateConfig(t *testing.T) {
|
||||
|
@ -25,3 +25,17 @@ func TestTemplateConfig(t *testing.T) {
|
|||
|
||||
require.Equal(DefaultConfig(), conf)
|
||||
}
|
||||
|
||||
func TestDefaults(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
require := require.New(t)
|
||||
|
||||
r := &Root{}
|
||||
dr := AddDefaults(r)
|
||||
require.NotNil(dr)
|
||||
require.NotNil(dr.Fuse)
|
||||
require.NotNil(dr.HTTPGlobal)
|
||||
require.NotNil(dr.Log)
|
||||
require.NotNil(dr.Torrent)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,9 @@ type WebDAVGlobal struct {
|
|||
}
|
||||
|
||||
type HTTPGlobal struct {
|
||||
Port int `yaml:"port"`
|
||||
Port int `yaml:"port"`
|
||||
IP string `yaml:"ip"`
|
||||
HTTPFS bool `yaml:"httpfs"`
|
||||
}
|
||||
|
||||
type FuseGlobal struct {
|
||||
|
@ -63,8 +65,13 @@ func AddDefaults(r *Root) *Root {
|
|||
if r.Torrent == nil {
|
||||
r.Torrent = &TorrentGlobal{}
|
||||
}
|
||||
|
||||
if r.Torrent.AddTimeout == 0 {
|
||||
r.Torrent.AddTimeout = 60
|
||||
}
|
||||
|
||||
if r.Torrent.GlobalCacheSize == 0 {
|
||||
r.Torrent.GlobalCacheSize = 1024 // 1GB
|
||||
r.Torrent.GlobalCacheSize = 2048 // 2GB
|
||||
}
|
||||
|
||||
if r.Torrent.MetadataFolder == "" {
|
||||
|
@ -78,5 +85,17 @@ func AddDefaults(r *Root) *Root {
|
|||
r.Fuse.Path = mountFolder
|
||||
}
|
||||
|
||||
if r.HTTPGlobal == nil {
|
||||
r.HTTPGlobal = &HTTPGlobal{}
|
||||
}
|
||||
|
||||
if r.HTTPGlobal.IP == "" {
|
||||
r.HTTPGlobal.IP = "0.0.0.0"
|
||||
}
|
||||
|
||||
if r.Log == nil {
|
||||
r.Log = &Log{}
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue