diff --git a/Dockerfile b/Dockerfile index 3a6b4c7..9ace972 100644 --- a/Dockerfile +++ b/Dockerfile @@ -100,7 +100,7 @@ COPY --from=frontend-builder /frontend/dist /app/frontend-dist # Final setup: permissions and directories in one layer # Only creating directories and setting executable bits. # Ownership will be handled by the entrypoint script. -RUN mkdir -p /var/log/cwa-book-downloader /cwa-book-ingest && \ +RUN mkdir -p /var/log/cwa-book-downloader /books && \ chmod +x /app/entrypoint.sh /app/tor.sh /app/genDebug.sh # Expose the application port diff --git a/cwa_book_downloader/config/settings.py b/cwa_book_downloader/config/settings.py index 23f1bc1..070e830 100644 --- a/cwa_book_downloader/config/settings.py +++ b/cwa_book_downloader/config/settings.py @@ -27,14 +27,8 @@ logger.debug(f"BASE_DIR: {BASE_DIR}") if env.ENABLE_LOGGING: env.LOG_DIR.mkdir(exist_ok=True) -# Create necessary directories +# Create staging directory (destination is created by orchestrator using config value) env.TMP_DIR.mkdir(exist_ok=True) -env.INGEST_DIR.mkdir(exist_ok=True) - -CROSS_FILE_SYSTEM = os.stat(env.TMP_DIR).st_dev != os.stat(env.INGEST_DIR).st_dev -logger.debug(f"STAT TMP_DIR: {os.stat(env.TMP_DIR)}") -logger.debug(f"STAT INGEST_DIR: {os.stat(env.INGEST_DIR)}") -logger.debug(f"CROSS_FILE_SYSTEM: {CROSS_FILE_SYSTEM}") # DNS placeholders - actual values set by network.init() from config/ENV CUSTOM_DNS: list[str] = [] @@ -453,6 +447,7 @@ def download_settings(): description="Directory where downloaded files are saved.", default="/books", required=True, + env_var="INGEST_DIR", # Legacy env var name for backwards compatibility ), SelectField( key="FILE_ORGANIZATION", diff --git a/entrypoint.sh b/entrypoint.sh index e409ac1..d9d14ba 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -127,7 +127,7 @@ change_ownership /tmp/cwa-book-downloader # Test write to all folders make_writable ${CONFIG_DIR:-/config} -make_writable /cwa-book-ingest +make_writable ${INGEST_DIR:-/books} # Always run Gunicorn (even when DEBUG=true) to ensure Socket.IO WebSocket # upgrades work reliably on customer machines. diff --git a/genDebug.sh b/genDebug.sh index 5c942da..2a72b30 100755 --- a/genDebug.sh +++ b/genDebug.sh @@ -100,8 +100,8 @@ echo "=== Permissions ===" > "$LOG_DIR/permissions.txt" echo "ls -all /app" >> "$LOG_DIR/permissions.txt" ls -all /app >> "$LOG_DIR/permissions.txt" 2>&1 echo "" >> "$LOG_DIR/permissions.txt" -echo "ls -all /cwa-book-ingest" >> "$LOG_DIR/permissions.txt" -ls -all /cwa-book-ingest >> "$LOG_DIR/permissions.txt" 2>&1 +echo "ls -all ${INGEST_DIR:-/books}" >> "$LOG_DIR/permissions.txt" +ls -all ${INGEST_DIR:-/books} >> "$LOG_DIR/permissions.txt" 2>&1 echo "" >> "$LOG_DIR/permissions.txt" echo "ls -all /var/log/cwa-book-downloader" >> "$LOG_DIR/permissions.txt" ls -all /var/log/cwa-book-downloader >> "$LOG_DIR/permissions.txt" 2>&1 diff --git a/readme.md b/readme.md index a86bc4c..39f068e 100644 --- a/readme.md +++ b/readme.md @@ -60,7 +60,7 @@ That's it! Configure settings through the web interface as needed. ```yaml volumes: - /your/config/path:/config # Config, database, and artwork cache directory - - /your/download/path:/cwa-book-ingest # Downloaded books + - /your/download/path:/books # Downloaded books ``` > **Tip**: Point the download volume to your CWA or Booklore ingest folder for automatic import. @@ -90,7 +90,7 @@ Environment variables work for initial setup and Docker deployments. They serve | Variable | Description | Default | |----------|-------------|---------| | `FLASK_PORT` | Web interface port | `8084` | -| `INGEST_DIR` | Book download directory | `/cwa-book-ingest` | +| `INGEST_DIR` | Book download directory | `/books` | | `TZ` | Container timezone | `UTC` | | `PUID` / `PGID` | Runtime user/group ID (also supports legacy `UID`/`GID`) | `1000` / `1000` | | `SEARCH_MODE` | `direct` or `universal` | `direct` | diff --git a/tests/config/test_docker_volumes.py b/tests/config/test_docker_volumes.py index c95d4d3..b999744 100644 --- a/tests/config/test_docker_volumes.py +++ b/tests/config/test_docker_volumes.py @@ -415,9 +415,9 @@ class TestCrossFilesystem: assert os.stat(tmp_dir).st_dev == os.stat(ingest_dir).st_dev def test_detect_cross_filesystem(self): - """CROSS_FILE_SYSTEM detection should work.""" - # This is a documentation test - the actual logic is in settings.py: - # CROSS_FILE_SYSTEM = os.stat(env.TMP_DIR).st_dev != os.stat(env.INGEST_DIR).st_dev + """Cross-filesystem detection uses same_filesystem() at runtime.""" + # Detection is done lazily by same_filesystem() in core/naming.py + # when hardlinking is attempted, not at startup pass