Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
agkyra
Commits
f2eeddd9
Commit
f2eeddd9
authored
Oct 15, 2015
by
Stavros Sachtouris
Committed by
Giorgos Korfiatis
Oct 19, 2015
Browse files
Reset backend when changing essential settings
parent
87655bd2
Changes
1
Hide whitespace changes
Inline
Side-by-side
agkyra/protocol.py
View file @
f2eeddd9
...
...
@@ -548,22 +548,31 @@ class WebSocketProtocol(WebSocket):
"""Set the settings and dump them to permanent storage if needed"""
# Prepare setting save
could_sync
=
self
.
syncer
and
self
.
can_sync
()
was_active
=
False
if
could_sync
and
not
self
.
syncer
.
paused
:
was_active
=
True
self
.
pause_sync
()
old_status
=
self
.
get_status
(
'code'
)
active
=
(
STATUS
[
'SYNCING'
],
STATUS
[
'PAUSING'
],
STATUS
[
'PAUSED'
])
must_reset_syncing
=
self
.
_essentials_changed
(
new_settings
)
if
must_reset_syncing
and
old_status
in
active
:
LOGGER
.
debug
(
'Temporary backend shutdown to save settings'
)
self
.
shutdown_syncer
()
# save settings
self
.
settings
.
update
(
new_settings
)
self
.
_dump_settings
()
# Restart
if
self
.
can_sync
():
if
must_reset_syncing
or
not
could_sync
:
self
.
init_sync
()
if
was_active
:
self
.
start_sync
()
LOGGER
.
debug
(
'Reload settings'
)
self
.
_load_settings
()
can_sync
=
must_reset_syncing
and
self
.
can_sync
()
if
can_sync
:
LOGGER
.
debug
(
'Restart backend'
)
self
.
init_sync
()
new_status
=
self
.
get_status
(
'code'
)
if
new_status
in
active
:
must_sync
=
old_status
==
STATUS
[
'SYNCING'
]
or
(
old_status
not
in
active
and
(
self
.
settings
.
get
(
'sync_on_start'
,
False
)))
(
self
.
start_sync
if
must_sync
else
self
.
pause_sync
)()
def
_pause_syncer
(
self
):
syncer_
=
self
.
syncer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment