Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion fileglancer/apps/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async def _ensure_repo_cache(url: str, pull: bool = False,

When username is provided, the work is delegated to a worker subprocess
that runs with the target user's real UID/GID, avoiding the process-wide
euid race condition that EffectiveUserContext has with concurrent async
euid race condition that seteuid/setegid has with concurrent async
requests. When username is None, git commands run in-process (used by
the worker subprocess itself, or in single-user dev mode).
"""
Expand Down
29 changes: 29 additions & 0 deletions fileglancer/filestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,35 @@ def stream_file_range(self, path: str = None, start: int = 0, end: int = 0, buff
file_handle.close()


@staticmethod
def _stream_contents(file_handle, buffer_size: int = DEFAULT_BUFFER_SIZE) -> Generator[bytes, None, None]:
"""Stream from an open file handle. Handle is closed when done."""
try:
while True:
chunk = file_handle.read(buffer_size)
if not chunk:
break
yield chunk
finally:
file_handle.close()

@staticmethod
def _stream_range(start: int, end: int, content_length: int,
file_handle, buffer_size: int = DEFAULT_BUFFER_SIZE) -> Generator[bytes, None, None]:
"""Stream a byte range from an open file handle. Handle is closed when done."""
try:
file_handle.seek(start)
remaining = content_length
while remaining > 0:
chunk_size = min(buffer_size, remaining)
chunk = file_handle.read(chunk_size)
if not chunk:
break
yield chunk
remaining -= len(chunk)
finally:
file_handle.close()

def rename_file_or_dir(self, old_path: str, new_path: str):
"""
Rename a file at the given old path to the new path.
Expand Down
691 changes: 315 additions & 376 deletions fileglancer/server.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions fileglancer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class Settings(BaseSettings):
# Useful for setting up scheduler env (e.g., /misc/lsf/conf/profile.lsf).
env_source_script: Optional[str] = None

# Worker pool settings
worker_pool_max_workers: int = 50
worker_pool_idle_timeout: int = 300 # seconds

# Cluster / Apps settings (mirrors py-cluster-api ClusterConfig)
cluster: ClusterSettings = ClusterSettings()

Expand Down
132 changes: 0 additions & 132 deletions fileglancer/user_context.py

This file was deleted.

Loading
Loading