diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index cc91fadb6..14a0650f0 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -50,6 +50,7 @@ map_folders() { # Export these so they can be used in docker-prepare.sh export DATA_DIR="${PAPERLESS_DATA_DIR:-/usr/src/paperless/data}" export MEDIA_ROOT_DIR="${PAPERLESS_MEDIA_ROOT:-/usr/src/paperless/media}" + export CONSUME_DIR="${PAPERLESS_CONSUMPTION_DIR:-/usr/src/paperless/consume}" } initialize() { @@ -77,7 +78,11 @@ initialize() { local export_dir="/usr/src/paperless/export" - for dir in "${export_dir}" "${DATA_DIR}" "${DATA_DIR}/index" "${MEDIA_ROOT_DIR}" "${MEDIA_ROOT_DIR}/documents" "${MEDIA_ROOT_DIR}/documents/originals" "${MEDIA_ROOT_DIR}/documents/thumbnails"; do + for dir in \ + "${export_dir}" \ + "${DATA_DIR}" "${DATA_DIR}/index" \ + "${MEDIA_ROOT_DIR}" "${MEDIA_ROOT_DIR}/documents" "${MEDIA_ROOT_DIR}/documents/originals" "${MEDIA_ROOT_DIR}/documents/thumbnails" \ + "${CONSUME_DIR}"; do if [[ ! -d "${dir}" ]]; then echo "Creating directory ${dir}" mkdir "${dir}" @@ -91,7 +96,11 @@ initialize() { set +e echo "Adjusting permissions of paperless files. This may take a while." chown -R paperless:paperless ${tmp_dir} - for dir in "${export_dir}" "${DATA_DIR}" "${MEDIA_ROOT_DIR}"; do + for dir in \ + "${export_dir}" \ + "${DATA_DIR}" \ + "${MEDIA_ROOT_DIR}" \ + "${CONSUME_DIR}"; do find "${dir}" -not \( -user paperless -and -group paperless \) -exec chown paperless:paperless {} + done set -e diff --git a/src/paperless/checks.py b/src/paperless/checks.py index c9ac5cb6a..e592a5bf2 100644 --- a/src/paperless/checks.py +++ b/src/paperless/checks.py @@ -1,4 +1,6 @@ +import grp import os +import pwd import shutil import stat @@ -32,12 +34,15 @@ def path_check(var, directory): with open(test_file, "w"): pass except PermissionError: + dir_stat = os.stat(directory) + dir_mode = stat.filemode(dir_stat.st_mode) + dir_owner = pwd.getpwuid(dir_stat.st_uid).pw_name + dir_group = grp.getgrgid(dir_stat.st_gid).gr_name messages.append( Error( writeable_message.format(var), writeable_hint.format( - f"\n{stat.filemode(os.stat(directory).st_mode)} " - f"{directory}\n", + f"\n{dir_mode} {dir_owner} {dir_group} " f"{directory}\n", ), ), )