From 2797efdc25e829d8d7f075352172b64a395e3065 Mon Sep 17 00:00:00 2001 From: Jose134 Date: Sun, 2 Feb 2025 01:43:43 +0100 Subject: [PATCH] Install czkawka via download in dockerfile + fix uvicorn dependency --- .gitignore | 6 +----- Dockerfile | 12 +++++++----- requirements.txt | 2 ++ src/deduplication.py | 10 +--------- src/main.py | 3 +-- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index c76fa4f..efa407c 100644 --- a/.gitignore +++ b/.gitignore @@ -159,8 +159,4 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - - -vendor/czkawka/* -vendor/ffmpeg/* \ No newline at end of file +#.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4bb6c45..11930b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,13 +14,15 @@ RUN pip install --no-cache-dir -r requirements.txt RUN pip install gunicorn # Copy the FastAPI project files into the container -COPY . . +COPY src/ . -# Copy the czkawka binary into the container -COPY vendor/czkawka /bin/ +# Copy the patterns.txt file into the container +COPY config/patterns.txt /config/patterns.txt -# Install ffmpeg with ffprobe -RUN apt-get update && apt-get install -y ffmpeg +# Install binary dependencies +RUN apt-get update && apt-get install -y wget ffmpeg +RUN wget -O /usr/local/bin/czkawka https://github.com/qarmin/czkawka/releases/download/8.0.0/linux_czkawka_cli +RUN chmod +x /usr/local/bin/czkawka # Expose the port the app runs on EXPOSE 8000 diff --git a/requirements.txt b/requirements.txt index 49e0235..4ac5332 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ requests +python-dotenv fastapi +uvicorn pytest ; extra == 'dev' \ No newline at end of file diff --git a/src/deduplication.py b/src/deduplication.py index 9f4f1dd..ed0f456 100644 --- a/src/deduplication.py +++ b/src/deduplication.py @@ -10,15 +10,7 @@ class CZKAWKA_DELETION_METHOD(Enum): NONE="NONE" def deduplicate_files(target_dir, exclude_files): - executables = { - "linux": "linux_czkawka_cli", - "win32": "windows_czkawka_cli.exe", - "darwin": "mac_czkawka_cli", - "docker": "linux_czkawka_cli" - } - - platform = "docker" if os.path.exists("/.dockerenv") else os.sys.platform - czkawka_executable = executables.get(platform, "czkawka_cli") + czkawka_executable = "czkawka" czkawka_deletion_method = CZKAWKA_DELETION_METHOD.ALL_EXCEPT_SMALLEST czkawka_tolerance = os.environ.get("CK_DUPLICATE_TOLERANCE", "2") _remove_duplicates(czkawka_executable, target_dir, exclude_files, czkawka_deletion_method, czkawka_tolerance) diff --git a/src/main.py b/src/main.py index 6fdf5ec..a9852af 100644 --- a/src/main.py +++ b/src/main.py @@ -7,9 +7,8 @@ from qbittorrent_api import get_qbittorrent_files_downloading from filemoving import group_files_by_prefix from deduplication import deduplicate_files import uuid -import time -logger = logging.getLogger(__name__) +logger = logging.getLogger(__name__).setLevel(logging.INFO) load_dotenv()