From e8abbe0623a842aaf58debf4a819f2057abdf3e9 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Tue, 22 Oct 2024 14:50:56 +0800 Subject: [PATCH] fix(storage): ensure `storage_runner` initialization within app context (#9627) --- api/extensions/ext_storage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/extensions/ext_storage.py b/api/extensions/ext_storage.py index 50c5d7aebc..86fadf23d7 100644 --- a/api/extensions/ext_storage.py +++ b/api/extensions/ext_storage.py @@ -15,7 +15,8 @@ class Storage: def init_app(self, app: Flask): storage_factory = self.get_storage_factory(dify_config.STORAGE_TYPE) - self.storage_runner = storage_factory() + with app.app_context(): + self.storage_runner = storage_factory() @staticmethod def get_storage_factory(storage_type: str) -> type[BaseStorage]: