Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions app/demo_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ def _headtail(
lines: int | None,
skip_heading: bool = False,
skip_trailing: bool = False,
) -> Tuple[Any, int]:
) -> Any:
args = [cmd]

if cmd == "tail" and skip_heading:
Expand All @@ -754,8 +754,7 @@ def _headtail(
args.append(rp)

result = self._run(args)
content = result.stdout
return content, len(content)
return result.stdout

async def head(
self: "DemoAdapter",
Expand All @@ -766,7 +765,7 @@ async def head(
lines: int | None,
skip_trailing: bool = False,
) -> filesystem_models.GetFileHeadResponse:
content, offset = self._headtail("head", path, file_bytes, lines, skip_trailing=skip_trailing)
content = self._headtail("head", path, file_bytes, lines, skip_trailing=skip_trailing)

fc = filesystem_models.FileContent(
content=content,
Expand All @@ -776,7 +775,7 @@ async def head(
start_position=0,
end_position=len(content))

return filesystem_models.GetFileHeadResponse(output=fc, offset=offset)
return filesystem_models.GetFileHeadResponse(output=fc)

async def tail(
self: "DemoAdapter",
Expand All @@ -788,7 +787,7 @@ async def tail(
skip_heading: bool = False,
) -> filesystem_models.GetFileTailResponse:

content, offset = self._headtail("tail", path, file_bytes, lines, skip_heading=skip_heading)
content = self._headtail("tail", path, file_bytes, lines, skip_heading=skip_heading)

fc = filesystem_models.FileContent(
content=content,
Expand All @@ -798,7 +797,7 @@ async def tail(
start_position=0,
end_position=len(content))

return filesystem_models.GetFileTailResponse(output=fc, offset=offset)
return filesystem_models.GetFileTailResponse(output=fc)



Expand Down
2 changes: 0 additions & 2 deletions app/routers/filesystem/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ class GetDirectoryLsResponse(BaseModel):
class GetFileHeadResponse(BaseModel):
"""Represents the response for reading the beginning of a file."""
output: FileContent = Field(default=None, description="File content from the beginning")
offset: int = Field(default=0, description="Offset in bytes from the beginning of the file where to start reading the content", example=0)


class GetFileTailResponse(BaseModel):
"""Represents the response for reading the end of a file."""
output: FileContent = Field(default=None, description="File content from the end")
offset: int = Field(default=0, description="Offset in bytes from the beginning of the file where to start reading the content", example=0)


class GetFileChecksumResponse(BaseModel):
Expand Down