From e89fd686e2131479639f50098fe3120484907ea0 Mon Sep 17 00:00:00 2001 From: Magicbook1108 Date: Thu, 12 Feb 2026 15:40:55 +0800 Subject: [PATCH] Improve: optimize file name (with path) in box container. (#13124) ### What problem does this PR solve? Refact: optimize file name (with path) in box container. ### Type of change - [x] Performance Improvement image --- common/data_source/box_connector.py | 27 ++++++++++++++++++++++----- web/vite.config.ts | 7 ------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/common/data_source/box_connector.py b/common/data_source/box_connector.py index 3006e709c9..253029d3c9 100644 --- a/common/data_source/box_connector.py +++ b/common/data_source/box_connector.py @@ -38,9 +38,10 @@ class BoxConnector(LoadConnector, PollConnector): def _yield_files_recursive( self, - folder_id, + folder_id: str, start: SecondsSinceUnixEpoch | None, - end: SecondsSinceUnixEpoch | None + end: SecondsSinceUnixEpoch | None, + relative_folder_path: str = "", ) -> GenerateDocumentsOutput: if self.box_client is None: @@ -59,6 +60,7 @@ class BoxConnector(LoadConnector, PollConnector): file = self.box_client.files.get_file_by_id( entry.id ) + modified_time: SecondsSinceUnixEpoch | None = None raw_time = ( getattr(file, "created_at", None) or getattr(file, "content_created_at", None) @@ -72,13 +74,18 @@ class BoxConnector(LoadConnector, PollConnector): continue content_bytes = self.box_client.downloads.download_file(file.id) + semantic_identifier = ( + f"{relative_folder_path} / {file.name}" + if relative_folder_path + else file.name + ) batch.append( Document( id=f"box:{file.id}", blob=content_bytes.read(), source=DocumentSource.BOX, - semantic_identifier=file.name, + semantic_identifier=semantic_identifier, extension=get_file_ext(file.name), doc_updated_at=modified_time, size_bytes=file.size, @@ -86,7 +93,17 @@ class BoxConnector(LoadConnector, PollConnector): ) ) elif entry.type == 'folder': - yield from self._yield_files_recursive(folder_id=entry.id, start=start, end=end) + child_relative_path = ( + f"{relative_folder_path} / {entry.name}" + if relative_folder_path + else entry.name + ) + yield from self._yield_files_recursive( + folder_id=entry.id, + start=start, + end=end, + relative_folder_path=child_relative_path + ) if batch: yield batch @@ -159,4 +176,4 @@ class BoxConnector(LoadConnector, PollConnector): if __name__ == "__main__": pass - # app.run(port=4999) \ No newline at end of file + # app.run(port=4999) diff --git a/web/vite.config.ts b/web/vite.config.ts index 3504176923..c1074708d2 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -65,18 +65,11 @@ export default defineConfig(({ mode, command }) => { overlay: false, }, proxy: { - '/api/v1/admin': { - target: 'http://127.0.0.1:9381/', - changeOrigin: true, - ws: true, - }, - '/api': { target: 'http://127.0.0.1:9380/', changeOrigin: true, ws: true, }, - '/v1': { target: 'http://127.0.0.1:9380/', changeOrigin: true,