syncthing_folder: Always update the devices the folder is shared with
Ensure all devices the folder should be shared with is part of the folder configuration. Previously, only at folder creation would the devices be set.
This commit is contained in:
parent
8b7b85b8f1
commit
83e9add60c
|
@ -108,4 +108,5 @@ Examples:
|
|||
## License
|
||||
|
||||
Copyright: (c) 2018, Rafael Bodill `<justrafi at g>`
|
||||
Copyright: (c) 2020, Borjan Tchakaloff `<first name at last name dot fr>`
|
||||
GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2018, Rafael Bodill <justrafi at gmail>
|
||||
# Copyright: (c) 2020, Borjan Tchakaloff <first name at last name dot fr>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
ANSIBLE_METADATA = {
|
||||
|
@ -242,8 +243,25 @@ def run_module():
|
|||
for folder in config['folders']:
|
||||
if folder['id'] == module.params['id']:
|
||||
want_pause = module.params['state'] == 'pause'
|
||||
if (want_pause and folder['paused']) or \
|
||||
(not want_pause and not folder['paused']):
|
||||
already_configured = (
|
||||
(want_pause and folder['paused'])
|
||||
or
|
||||
(not want_pause and not folder['paused'])
|
||||
)
|
||||
|
||||
want_devices = sorted([
|
||||
{
|
||||
'deviceID': device_id,
|
||||
'introducedBy': '',
|
||||
} for device_id in module.params['devices']
|
||||
], key=lambda d: d['deviceID'])
|
||||
already_configured = (
|
||||
already_configured
|
||||
and
|
||||
want_devices == sorted(folder['devices'], key=lambda d: d['deviceID'])
|
||||
)
|
||||
|
||||
if already_configured:
|
||||
module.exit_json(**result)
|
||||
else:
|
||||
folder['paused'] = want_pause
|
||||
|
|
Loading…
Reference in New Issue
Block a user