mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-31 14:01:56 +00:00
gui, lib/config, lib/model: Add ability to ignore folders offered by other nodes (fixes #3993)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4179 LGTM: AudriusButkevicius, calmh
This commit is contained in:
parent
3959eb26fb
commit
b49bbe82dd
@ -216,6 +216,9 @@
|
||||
<button type="button" class="btn btn-sm btn-default" ng-click="dismissFolderRejection(event.data.folder, event.data.device)">
|
||||
<span class="fa fa-clock-o"></span> <span translate>Later</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-default" ng-click="ignoreRejectedFolder(event.data.folder, event.data.device)">
|
||||
<span class="fa fa-times"></span> <span translate>Ignore</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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) {
|
||||
|
@ -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{}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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,
|
||||
|
@ -154,6 +154,7 @@ Returns the current configuration.
|
||||
"tempIndexMinBlocks": 10
|
||||
},
|
||||
"ignoredDevices": []
|
||||
"ignoredFolders": []
|
||||
}
|
||||
}
|
||||
.ft P
|
||||
|
Loading…
Reference in New Issue
Block a user