From 6bc2784e9acd943bd97654d0666f63a52b12b0b6 Mon Sep 17 00:00:00 2001 From: bt90 Date: Thu, 3 Apr 2025 14:28:33 +0200 Subject: [PATCH 1/3] build: replace underscore in Debian version (#10032) The workflow building Debian packages chokes on branches containing underscores: ``` {:timestamp=>"2025-04-03T10:31:46.749835+0000", :message=>"Invalid package configuration: The version looks invalid for Debian packages. Debian version field must contain only alphanumerics and . (period), + (plus), - (hyphen) or ~ (tilde). I have '1.29.5~dev.13.ga38df11f~srv_stun' which which isn't valid.", :level=>:error} ``` This replaces the offending `_` with a `~` which should yield a valid version. --- build.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.go b/build.go index 08d81414e..8b43a2b18 100644 --- a/build.go +++ b/build.go @@ -645,6 +645,9 @@ func buildDeb(target target) { // than just 0.14.26. This rectifies that. debver = strings.Replace(debver, "-", "~", -1) } + if strings.Contains(debver, "_") { + debver = strings.Replace(debver, "_", "~", -1) + } args := []string{ "-t", "deb", "-s", "dir", From 3e7ccf7c48e2b070b3783d0e1cba6995e0a9a228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20WENSKE?= Date: Fri, 4 Apr 2025 18:24:04 +0200 Subject: [PATCH 2/3] chore(model): add metric for total number of conflicts (#10037) --- lib/model/folder_sendrecv.go | 1 + lib/model/metrics.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/model/folder_sendrecv.go b/lib/model/folder_sendrecv.go index 73e3ef184..613aa1ca2 100644 --- a/lib/model/folder_sendrecv.go +++ b/lib/model/folder_sendrecv.go @@ -1854,6 +1854,7 @@ func (f *sendReceiveFolder) moveForConflict(name, lastModBy string, scanChan cha return nil } + metricFolderConflictsTotal.WithLabelValues(f.ID).Inc() newName := conflictName(name, lastModBy) err := f.mtimefs.Rename(name, newName) if fs.IsNotExist(err) { diff --git a/lib/model/metrics.go b/lib/model/metrics.go index ad211aecb..6627d027b 100644 --- a/lib/model/metrics.go +++ b/lib/model/metrics.go @@ -57,6 +57,13 @@ var ( Name: "folder_processed_bytes_total", Help: "Total amount of data processed during folder syncing, per folder ID and data source (network/local_origin/local_other/local_shifted/skipped)", }, []string{"folder", "source"}) + + metricFolderConflictsTotal = promauto.NewCounterVec(prometheus.CounterOpts{ + Namespace: "syncthing", + Subsystem: "model", + Name: "folder_conflicts_total", + Help: "Total number of conflicts", + }, []string{"folder"}) ) const ( @@ -90,4 +97,5 @@ func registerFolderMetrics(folderID string) { metricFolderProcessedBytesTotal.WithLabelValues(folderID, metricSourceLocalOther) metricFolderProcessedBytesTotal.WithLabelValues(folderID, metricSourceLocalShifted) metricFolderProcessedBytesTotal.WithLabelValues(folderID, metricSourceSkipped) + metricFolderConflictsTotal.WithLabelValues(folderID) } From f7c8efd93c49ad0bb865b117b5b3d244622a5712 Mon Sep 17 00:00:00 2001 From: Tommy van der Vorst Date: Fri, 4 Apr 2025 18:46:12 +0200 Subject: [PATCH 3/3] fix(config): properly apply defaults when reading folder configuration (#10034) --- lib/config/config_test.go | 12 ++++++++---- lib/config/folderconfiguration.go | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/lib/config/config_test.go b/lib/config/config_test.go index b4d61fab4..1c2d8071b 100644 --- a/lib/config/config_test.go +++ b/lib/config/config_test.go @@ -101,7 +101,7 @@ func TestDefaultValues(t *testing.T) { Defaults: Defaults{ Folder: FolderConfiguration{ FilesystemType: FilesystemTypeBasic, - Path: "~", + Path: "", Type: FolderTypeSendReceive, Devices: []FolderDeviceConfiguration{{DeviceID: device1}}, RescanIntervalS: 3600, @@ -181,7 +181,7 @@ func TestDeviceConfig(t *testing.T) { Devices: []FolderDeviceConfiguration{{DeviceID: device1}, {DeviceID: device4}}, Type: FolderTypeSendOnly, RescanIntervalS: 600, - FSWatcherEnabled: false, + FSWatcherEnabled: true, FSWatcherDelayS: 10, Copiers: 0, Hashers: 0, @@ -189,14 +189,18 @@ func TestDeviceConfig(t *testing.T) { MinDiskFree: Size{1, "%"}, MaxConflicts: -1, Versioning: VersioningConfiguration{ - Params: map[string]string{}, + CleanupIntervalS: 3600, + FSType: FilesystemTypeBasic, + Params: map[string]string{}, }, WeakHashThresholdPct: 25, MarkerName: DefaultMarkerName, JunctionsAsDirs: true, MaxConcurrentWrites: maxConcurrentWritesDefault, XattrFilter: XattrFilter{ - Entries: []XattrFilterEntry{}, + MaxSingleEntrySize: 1024, + MaxTotalSize: 4096, + Entries: []XattrFilterEntry{}, }, }, } diff --git a/lib/config/folderconfiguration.go b/lib/config/folderconfiguration.go index 786be1f8d..715bff8c9 100644 --- a/lib/config/folderconfiguration.go +++ b/lib/config/folderconfiguration.go @@ -9,6 +9,8 @@ package config import ( "bytes" "crypto/sha256" + "encoding/json" + "encoding/xml" "errors" "fmt" "path" @@ -23,6 +25,7 @@ import ( "github.com/syncthing/syncthing/lib/db" "github.com/syncthing/syncthing/lib/fs" "github.com/syncthing/syncthing/lib/protocol" + "github.com/syncthing/syncthing/lib/structutil" ) var ( @@ -48,7 +51,7 @@ 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" default:"basic"` - Path string `json:"path" xml:"path,attr" default:"~"` + Path string `json:"path" xml:"path,attr"` Type FolderType `json:"type" xml:"type,attr"` Devices []FolderDeviceConfiguration `json:"devices" xml:"device"` RescanIntervalS int `json:"rescanIntervalS" xml:"rescanIntervalS,attr" default:"3600"` @@ -399,3 +402,23 @@ func (f XattrFilter) GetMaxSingleEntrySize() int { func (f XattrFilter) GetMaxTotalSize() int { return f.MaxTotalSize } + +func (f *FolderConfiguration) UnmarshalJSON(data []byte) error { + structutil.SetDefaults(f) + + // avoid recursing into this method + type noCustomUnmarshal FolderConfiguration + ptr := (*noCustomUnmarshal)(f) + + return json.Unmarshal(data, ptr) +} + +func (f *FolderConfiguration) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + structutil.SetDefaults(f) + + // avoid recursing into this method + type noCustomUnmarshal FolderConfiguration + ptr := (*noCustomUnmarshal)(f) + + return d.DecodeElement(ptr, &start) +}