Allow full library refresh interval. fix #2807
This commit is contained in:
@@ -52,6 +52,20 @@ class Manage(Plugin):
|
|||||||
if not Env.get('dev') and self.conf('startup_scan'):
|
if not Env.get('dev') and self.conf('startup_scan'):
|
||||||
addEvent('app.load', self.updateLibraryQuick)
|
addEvent('app.load', self.updateLibraryQuick)
|
||||||
|
|
||||||
|
addEvent('app.load', self.setCrons)
|
||||||
|
|
||||||
|
# Enable / disable interval
|
||||||
|
addEvent('setting.save.manage.library_refresh_interval.after', self.setCrons)
|
||||||
|
|
||||||
|
def setCrons(self):
|
||||||
|
|
||||||
|
fireEvent('schedule.remove', 'manage.update_library')
|
||||||
|
refresh = tryInt(self.conf('library_refresh_interval'))
|
||||||
|
if refresh > 0:
|
||||||
|
fireEvent('schedule.interval', 'manage.update_library', self.updateLibrary, hours = refresh, single = True)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def getProgress(self, **kwargs):
|
def getProgress(self, **kwargs):
|
||||||
return {
|
return {
|
||||||
'progress': self.in_progress
|
'progress': self.in_progress
|
||||||
@@ -162,6 +176,10 @@ class Manage(Plugin):
|
|||||||
used_files[release_file] = release
|
used_files[release_file] = release
|
||||||
del used_files
|
del used_files
|
||||||
|
|
||||||
|
# Break if CP wants to shut down
|
||||||
|
if self.shuttingDown():
|
||||||
|
break
|
||||||
|
|
||||||
Env.prop(last_update_key, time.time())
|
Env.prop(last_update_key, time.time())
|
||||||
except:
|
except:
|
||||||
log.error('Failed updating library: %s', (traceback.format_exc()))
|
log.error('Failed updating library: %s', (traceback.format_exc()))
|
||||||
@@ -308,6 +326,14 @@ config = [{
|
|||||||
'advanced': True,
|
'advanced': True,
|
||||||
'description': 'Do a quick scan on startup. On slow systems better disable this.',
|
'description': 'Do a quick scan on startup. On slow systems better disable this.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'label': 'Full library refresh',
|
||||||
|
'name': 'library_refresh_interval',
|
||||||
|
'type': 'int',
|
||||||
|
'default': 0,
|
||||||
|
'advanced': True,
|
||||||
|
'description': 'Do a full scan every X hours. (0 is disabled)',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user