1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-09-19 19:01:03 +00:00

Added a config variable to define if the watcher should be started

This commit is contained in:
spl0k 2019-04-13 17:14:03 +02:00
parent 55e9db61d8
commit 3924ada03e
4 changed files with 15 additions and 3 deletions

View File

@ -35,6 +35,9 @@ log_level = WARNING
; Default: /tmp/supysonic/supysonic.sock
socket = /var/run/supysonic.sock
; Defines if the file watcher should be started. Default: yes
run_watcher = yes
; Delay before triggering scanning operation after a change have been detected
; This prevents running too many scans when multiple changes are detected for a
; single file over a short time span. Default: 5

View File

@ -132,6 +132,9 @@ between the daemon and clients that rely on it (eg. CLI, folder admin web page,
etc.). Note that using an IP address here isn't supported.
Default: /tmp/supysonic/supysonic.sock
`run_watcher`: whether or not to start the watcher that will listen for library
changes. Default: yes
`wait_delay`: delay before triggering the scanning operation after a change
have been detected. This prevents running too many scans when multiple changes
are detected for a single file over a short time span. Default: 5 seconds.
@ -149,6 +152,9 @@ If left empty, any logging will be sent to stderr.
; Default: /tmp/supysonic/supysonic.sock
socket = /var/run/supysonic.sock
; Defines if the file watcher should be started. Default: yes
run_watcher = yes
; Delay before triggering scanning operation after a change have been detected
; This prevents running too many scans when multiple changes are detected for a
; single file over a short time span. Default: 5

View File

@ -40,6 +40,7 @@ class DefaultConfig(object):
}
DAEMON = {
'socket': os.path.join(tempdir, 'supysonic.sock'),
'run_watcher': True,
'wait_delay': 5,
'log_file': None,
'log_level': 'WARNING'

View File

@ -62,7 +62,8 @@ class Daemon(object):
def __handle_connection(self, connection):
try:
module, cmd, args = connection.recv()
if module == WATCHER:
logger.debug('Received %s %s %s', module, cmd, args)
if module == WATCHER and self.__watcher is not None:
if cmd == W_ADD:
self.__watcher.add_folder(*args)
elif cmd == W_DEL:
@ -74,6 +75,7 @@ class Daemon(object):
self.__listener = Listener(address = self.__address, authkey = get_secret_key('daemon_key'))
logger.info("Listening to %s", self.__listener.address)
if config.DAEMON['run_watcher']:
self.__watcher = SupysonicWatcher(config)
self.__watcher.start()