Add HTTPFS implementation ()

This commit is contained in:
Antonio Navarro Perez 2021-11-23 13:05:49 +01:00 committed by GitHub
parent 1d769673ca
commit 47198b3bc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 549 additions and 44 deletions

View file

@ -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,

View file

@ -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)
}

View file

@ -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
}