From 8de62759124d10b1f464f7128490c030be838826 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Tue, 5 May 2026 13:51:52 +0800 Subject: [PATCH] fix(file): handle empty text segment reads --- modules/container_file_proxy.py | 10 ++++++++++ modules/file_manager.py | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/modules/container_file_proxy.py b/modules/container_file_proxy.py index a2ee6a2..ce8b158 100644 --- a/modules/container_file_proxy.py +++ b/modules/container_file_proxy.py @@ -122,6 +122,16 @@ def _read_text_segment(root, payload): } data, lines = _read_text(target) total = len(lines) + if total == 0: + return { + "success": True, + "path": rel, + "content": "", + "size": size, + "line_start": 0, + "line_end": 0, + "total_lines": 0 + } line_start = start if start and start > 0 else 1 line_end = end if end and end >= line_start else total if line_start > total: diff --git a/modules/file_manager.py b/modules/file_manager.py index 97233f5..cd84f03 100644 --- a/modules/file_manager.py +++ b/modules/file_manager.py @@ -495,6 +495,17 @@ class FileManager: lines = result["lines"] total_lines = len(lines) + if total_lines == 0: + relative_path = self._relative_path(full_path) + return { + "success": True, + "path": relative_path, + "content": "", + "size": result["size"], + "line_start": 0, + "line_end": 0, + "total_lines": 0, + } start = start_line if start_line and start_line > 0 else 1 end = end_line if end_line and end_line >= start else total_lines if start > total_lines: