From 614f209f98d54fa0c1eb6724fa39a4440a54cf16 Mon Sep 17 00:00:00 2001 From: Karsten Lehmann Date: Wed, 2 Sep 2020 18:30:56 +0200 Subject: [PATCH] Removed unused post- and prehooks --- src/ankisyncd/sync_app.py | 53 --------------------------------------- 1 file changed, 53 deletions(-) diff --git a/src/ankisyncd/sync_app.py b/src/ankisyncd/sync_app.py index 90e70a2..d28bd6a 100644 --- a/src/ankisyncd/sync_app.py +++ b/src/ankisyncd/sync_app.py @@ -396,9 +396,6 @@ class SyncApp: self.base_media_url = config['base_media_url'] self.setup_new_collection = None - self.prehooks = {} - self.posthooks = {} - self.user_manager = get_user_manager(config) self.session_manager = get_session_manager(config) self.full_sync_manager = get_full_sync_manager(config) @@ -410,39 +407,6 @@ class SyncApp: if not self.base_media_url.endswith('/'): self.base_media_url += '/' - # backwards compat - @property - def hook_pre_sync(self): - return self.prehooks.get("start") - - @hook_pre_sync.setter - def hook_pre_sync(self, value): - self.prehooks['start'] = value - - @property - def hook_post_sync(self): - return self.posthooks.get("finish") - - @hook_post_sync.setter - def hook_post_sync(self, value): - self.posthooks['finish'] = value - - @property - def hook_upload(self): - return self.prehooks.get("upload") - - @hook_upload.setter - def hook_upload(self, value): - self.prehooks['upload'] = value - - @property - def hook_download(self): - return self.posthooks.get("download") - - @hook_download.setter - def hook_download(self, value): - self.posthooks['download'] = value - def generateHostKey(self, username): """Generates a new host key to be used by the given username to identify their session. This values is random.""" @@ -549,39 +513,22 @@ class SyncApp: self.session_manager.save(hkey, session) session = self.session_manager.load(hkey, self.create_session) - thread = session.get_thread() - - if url in self.prehooks: - thread.execute(self.prehooks[url], [session]) - result = self._execute_handler_method_in_thread(url, data, session) - # If it's a complex data type, we convert it to JSON if type(result) not in (str, bytes, Response): result = json.dumps(result) - if url in self.posthooks: - thread.execute(self.posthooks[url], [session]) - return result elif url == 'upload': thread = session.get_thread() - if url in self.prehooks: - thread.execute(self.prehooks[url], [session]) result = thread.execute(self.operation_upload, [data['data'], session]) - if url in self.posthooks: - thread.execute(self.posthooks[url], [session]) return result elif url == 'download': thread = session.get_thread() - if url in self.prehooks: - thread.execute(self.prehooks[url], [session]) result = thread.execute(self.operation_download, [session]) - if url in self.posthooks: - thread.execute(self.posthooks[url], [session]) return result # This was one of our operations but it didn't get handled... Oops!