diff --git a/gui/default/index.html b/gui/default/index.html index f72911c5..f623682f 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -216,6 +216,9 @@ + diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index a4708a49..8be48d6e 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -1532,6 +1532,12 @@ angular.module('syncthing.core') delete $scope.folderRejections[folder + "-" + device]; }; + $scope.ignoreRejectedFolder = function (folder, device) { + $scope.config.ignoredFolders.push(folder); + $scope.saveConfig(); + $scope.dismissFolderRejection(folder, device); + }; + $scope.sharesFolder = function (folderCfg) { var names = []; folderCfg.devices.forEach(function (device) { diff --git a/lib/config/config.go b/lib/config/config.go index 6d10bc03..75c474fb 100644 --- a/lib/config/config.go +++ b/lib/config/config.go @@ -155,6 +155,7 @@ type Configuration struct { GUI GUIConfiguration `xml:"gui" json:"gui"` Options OptionsConfiguration `xml:"options" json:"options"` IgnoredDevices []protocol.DeviceID `xml:"ignoredDevice" json:"ignoredDevices"` + IgnoredFolders []string `xml:"ignoredFolder" json:"ignoredFolders"` XMLName xml.Name `xml:"configuration" json:"-"` MyID protocol.DeviceID `xml:"-" json:"-"` // Provided by the instantiator. @@ -182,6 +183,10 @@ func (cfg Configuration) Copy() Configuration { newCfg.IgnoredDevices = make([]protocol.DeviceID, len(cfg.IgnoredDevices)) copy(newCfg.IgnoredDevices, cfg.IgnoredDevices) + // FolderConfiguraion.ID is type string + newCfg.IgnoredFolders = make([]string, len(cfg.IgnoredFolders)) + copy(newCfg.IgnoredFolders, cfg.IgnoredFolders) + return newCfg } @@ -238,6 +243,9 @@ func (cfg *Configuration) clean() error { if cfg.IgnoredDevices == nil { cfg.IgnoredDevices = []protocol.DeviceID{} } + if cfg.IgnoredFolders == nil { + cfg.IgnoredFolders = []string{} + } if cfg.Options.AlwaysLocalNets == nil { cfg.Options.AlwaysLocalNets = []string{} } diff --git a/lib/config/wrapper.go b/lib/config/wrapper.go index eeb70e69..234da75a 100644 --- a/lib/config/wrapper.go +++ b/lib/config/wrapper.go @@ -321,6 +321,19 @@ func (w *Wrapper) IgnoredDevice(id protocol.DeviceID) bool { return false } +// IgnoredFolder returns whether or not share attempts for the given +// folder should be silently ignored. +func (w *Wrapper) IgnoredFolder(folder string) bool { + w.mut.Lock() + defer w.mut.Unlock() + for _, nfolder := range w.cfg.IgnoredFolders { + if folder == nfolder { + return true + } + } + return false +} + // Device returns the configuration for the given device and an "ok" bool. func (w *Wrapper) Device(id protocol.DeviceID) (DeviceConfiguration, bool) { w.mut.Lock() diff --git a/lib/model/model.go b/lib/model/model.go index c8a7610e..73823dbd 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -809,6 +809,11 @@ func (m *Model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon continue } + if m.cfg.IgnoredFolder(folder.ID) { + l.Infof("Ignoring folder %s from device %s since we are configured to", folder.Description(), deviceID) + continue + } + if !m.folderSharedWithLocked(folder.ID, deviceID) { events.Default.Log(events.FolderRejected, map[string]string{ "folder": folder.ID, diff --git a/man/syncthing-rest-api.7 b/man/syncthing-rest-api.7 index dfb3ff79..a5db9b1f 100644 --- a/man/syncthing-rest-api.7 +++ b/man/syncthing-rest-api.7 @@ -154,6 +154,7 @@ Returns the current configuration. "tempIndexMinBlocks": 10 }, "ignoredDevices": [] + "ignoredFolders": [] } } .ft P