Skip to content

Commit

Permalink
Fix paperless-ngx-sync for directories with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ritiek committed Mar 4, 2025
1 parent d223ec9 commit 2915bb6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion machines/pilab/home/services/paperless-ngx.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ let
# Process each path pattern in the sync paths file
while IFS= read -r PATH_PATTERN; do
for FILE in $PATH_PATTERN; do
# Split pattern into directory and filename components
dir_part="$(dirname "$PATH_PATTERN")"
file_pattern="$(basename "$PATH_PATTERN")"
# Skip if directory doesn't exist
if [[ ! -d "$dir_part" ]]; then
echo "Directory does not exist: $dir_part"
continue
fi
# Expand files safely
shopt -s nullglob
files=("$dir_part"/$file_pattern) # Intentional unquoted $file_pattern for glob expansion
shopt -u nullglob
for FILE in "''${files[@]}"; do
if [[ -f "$FILE" ]]; then
FILE_CREATION_DATE=$(${pkgs.coreutils}/bin/stat -c %W "$FILE")
Expand Down

0 comments on commit 2915bb6

Please sign in to comment.