From caacc86ca9b46574929100992b0b07ca026166d8 Mon Sep 17 00:00:00 2001 From: cyclotruc Date: Thu, 2 Jan 2025 09:53:43 +0000 Subject: [PATCH] Fix tmp directory in docker container --- Dockerfile | 2 +- src/config.py | 2 +- src/gitingest/ingest.py | 6 ++---- src/gitingest/parse_query.py | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7d3a04f..564a5ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 # Install git RUN apt-get update \ - && apt-get install -y --no-install-recommends git \ + && apt-get install -y --no-install-recommends git curl\ && rm -rf /var/lib/apt/lists/* WORKDIR /app diff --git a/src/config.py b/src/config.py index 8da41da..fcbb22c 100644 --- a/src/config.py +++ b/src/config.py @@ -1,5 +1,5 @@ MAX_DISPLAY_SIZE: int = 300_000 -TMP_BASE_PATH: str = "../tmp" +TMP_BASE_PATH: str = "/tmp/gitingest" EXAMPLE_REPOS: list[dict[str, str]] = [ {"name": "Gitingest", "url": "https://github.com/cyclotruc/gitingest"}, diff --git a/src/gitingest/ingest.py b/src/gitingest/ingest.py index 4bb329f..da4a97a 100644 --- a/src/gitingest/ingest.py +++ b/src/gitingest/ingest.py @@ -1,7 +1,6 @@ import asyncio import inspect import shutil -from pathlib import Path from gitingest.clone import CloneConfig, clone_repo from gitingest.ingest_from_query import ingest_from_query @@ -79,10 +78,9 @@ def ingest( f.write(tree + "\n" + content) return summary, tree, content - finally: # Clean up the temporary directory if it was created if query["url"]: - # Get parent directory two levels up from local_path (../tmp) - cleanup_path = str(Path(query["local_path"]).parents[1]) + # Clean up the temporary directory under /tmp/gitingest + cleanup_path = "/tmp/gitingest" shutil.rmtree(cleanup_path, ignore_errors=True) diff --git a/src/gitingest/parse_query.py b/src/gitingest/parse_query.py index 859cafb..b10fd95 100644 --- a/src/gitingest/parse_query.py +++ b/src/gitingest/parse_query.py @@ -8,7 +8,7 @@ from gitingest.exceptions import InvalidPatternError from gitingest.ignore_patterns import DEFAULT_IGNORE_PATTERNS -TMP_BASE_PATH: str = "../tmp" +TMP_BASE_PATH: str = "/tmp/gitingest" HEX_DIGITS = set(string.hexdigits)