mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-13 04:54:23 +00:00
Automatically detect auth file changes and reloading those changes.
This commit is contained in:
parent
89d04a393b
commit
e552c21f66
@ -87,7 +87,7 @@ class Account(object):
|
|||||||
|
|
||||||
class AuthManager(component.Component):
|
class AuthManager(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
component.Component.__init__(self, "AuthManager")
|
component.Component.__init__(self, "AuthManager", interval=10)
|
||||||
self.__auth = {}
|
self.__auth = {}
|
||||||
self.__auth_modification_time = None
|
self.__auth_modification_time = None
|
||||||
|
|
||||||
@ -100,6 +100,26 @@ class AuthManager(component.Component):
|
|||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
log.debug("Querying for changed auth file")
|
||||||
|
auth_file = configmanager.get_config_dir("auth")
|
||||||
|
# Check for auth file and create if necessary
|
||||||
|
if not os.path.exists(auth_file):
|
||||||
|
log.info("Authfile not found, recreating it.")
|
||||||
|
self.__create_auth_file()
|
||||||
|
self.__create_localclient_account()
|
||||||
|
self.write_auth_file()
|
||||||
|
|
||||||
|
auth_file_modification_time = os.stat(auth_file).st_mtime
|
||||||
|
if self.__auth_modification_time is None:
|
||||||
|
self.__auth_modification_time = auth_file_modification_time
|
||||||
|
elif self.__auth_modification_time == auth_file_modification_time:
|
||||||
|
# File didn't change, no need for re-parsing's
|
||||||
|
return
|
||||||
|
|
||||||
|
log.info("auth file changed, reloading it!")
|
||||||
|
self.__load_auth_file()
|
||||||
|
|
||||||
def authorize(self, username, password):
|
def authorize(self, username, password):
|
||||||
"""
|
"""
|
||||||
Authorizes users based on username and password
|
Authorizes users based on username and password
|
||||||
|
Loading…
x
Reference in New Issue
Block a user