Merge branch 'main' into v2

* main:
  feat(fs, config): add support for custom filesystem type construction (#9887)
  build(deps): update dependencies (#10020)
This commit is contained in:
Jakob Borg
2025-04-03 10:21:01 +02:00
14 changed files with 132 additions and 119 deletions
+3 -1
View File
@@ -111,6 +111,7 @@ func TestDefaultValues(t *testing.T) {
AutoNormalize: true,
MinDiskFree: size,
Versioning: VersioningConfiguration{
FSType: FilesystemTypeBasic,
CleanupIntervalS: 3600,
Params: map[string]string{},
},
@@ -518,7 +519,8 @@ func TestIssue1750(t *testing.T) {
func TestFolderPath(t *testing.T) {
folder := FolderConfiguration{
Path: "~/tmp",
FilesystemType: FilesystemTypeBasic,
Path: "~/tmp",
}
realPath := folder.Filesystem().URI()
+13 -30
View File
@@ -8,47 +8,30 @@ package config
import "github.com/syncthing/syncthing/lib/fs"
type FilesystemType int32
type FilesystemType string
const (
FilesystemTypeBasic FilesystemType = 0
FilesystemTypeFake FilesystemType = 1
FilesystemTypeBasic FilesystemType = "basic"
FilesystemTypeFake FilesystemType = "fake"
)
func (t FilesystemType) String() string {
switch t {
case FilesystemTypeBasic:
return "basic"
case FilesystemTypeFake:
return "fake"
default:
return "unknown"
}
func (t FilesystemType) ToFS() fs.FilesystemType {
return fs.FilesystemType(string(t))
}
func (t FilesystemType) ToFS() fs.FilesystemType {
switch t {
case FilesystemTypeBasic:
return fs.FilesystemTypeBasic
case FilesystemTypeFake:
return fs.FilesystemTypeFake
default:
return fs.FilesystemTypeBasic
}
func (t FilesystemType) String() string {
return string(t)
}
func (t FilesystemType) MarshalText() ([]byte, error) {
return []byte(t.String()), nil
return []byte(t), nil
}
func (t *FilesystemType) UnmarshalText(bs []byte) error {
switch string(bs) {
case "basic":
*t = FilesystemTypeBasic
case "fake":
*t = FilesystemTypeFake
default:
*t = FilesystemTypeBasic
}
*t = FilesystemType(string(bs))
return nil
}
func (t *FilesystemType) ParseDefault(str string) error {
return t.UnmarshalText([]byte(str))
}
+1 -1
View File
@@ -46,7 +46,7 @@ type FolderDeviceConfiguration struct {
type FolderConfiguration struct {
ID string `json:"id" xml:"id,attr" nodefault:"true"`
Label string `json:"label" xml:"label,attr" restart:"false"`
FilesystemType FilesystemType `json:"filesystemType" xml:"filesystemType"`
FilesystemType FilesystemType `json:"filesystemType" xml:"filesystemType" default:"basic"`
Path string `json:"path" xml:"path,attr" default:"~"`
Type FolderType `json:"type" xml:"type,attr"`
Devices []FolderDeviceConfiguration `json:"devices" xml:"device"`
+2 -2
View File
@@ -20,7 +20,7 @@ type VersioningConfiguration struct {
Params map[string]string `json:"params" xml:"parameter" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
CleanupIntervalS int `json:"cleanupIntervalS" xml:"cleanupIntervalS" default:"3600"`
FSPath string `json:"fsPath" xml:"fsPath"`
FSType FilesystemType `json:"fsType" xml:"fsType"`
FSType FilesystemType `json:"fsType" xml:"fsType" default:"basic"`
}
func (c *VersioningConfiguration) Reset() {
@@ -33,7 +33,7 @@ type internalVersioningConfiguration struct {
Params []internalParam `xml:"param"`
CleanupIntervalS int `xml:"cleanupIntervalS" default:"3600"`
FSPath string `xml:"fsPath"`
FSType FilesystemType `xml:"fsType"`
FSType FilesystemType `xml:"fsType" default:"basic"`
}
type internalParam struct {