mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-11-04 12:30:12 +00:00 
			
		
		
		
	Fix consumedir to handle files/directories with spaces
This commit is contained in:
		@@ -167,8 +167,8 @@ info() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
getCollective() {
 | 
					getCollective() {
 | 
				
			||||||
    file="$(realpath $1)"
 | 
					    file=$(realpath "$1")
 | 
				
			||||||
    dir="$(realpath $2)"
 | 
					    dir=$(realpath "$2")
 | 
				
			||||||
    collective=${file#"$dir"}
 | 
					    collective=${file#"$dir"}
 | 
				
			||||||
    coll=$(echo $collective | cut -d'/' -f1)
 | 
					    coll=$(echo $collective | cut -d'/' -f1)
 | 
				
			||||||
    if [ -z "$coll" ]; then
 | 
					    if [ -z "$coll" ]; then
 | 
				
			||||||
@@ -179,8 +179,8 @@ getCollective() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
upload() {
 | 
					upload() {
 | 
				
			||||||
    dir="$(realpath $1)"
 | 
					    dir=$(realpath "$1")
 | 
				
			||||||
    file="$(realpath $2)"
 | 
					    file=$(realpath "$2")
 | 
				
			||||||
    url="$3"
 | 
					    url="$3"
 | 
				
			||||||
    OPTS="$CURL_OPTS"
 | 
					    OPTS="$CURL_OPTS"
 | 
				
			||||||
    if [ "$integration" = "y" ]; then
 | 
					    if [ "$integration" = "y" ]; then
 | 
				
			||||||
@@ -245,7 +245,7 @@ checkFile() {
 | 
				
			|||||||
    else
 | 
					    else
 | 
				
			||||||
        url=$(echo "$1" | sed 's,upload/item,checkfile,g')
 | 
					        url=$(echo "$1" | sed 's,upload/item,checkfile,g')
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    url="$url/$(checksum $file)"
 | 
					    url=$url/$(checksum "$file")
 | 
				
			||||||
    trace "- Check file via $OPTS: $url"
 | 
					    trace "- Check file via $OPTS: $url"
 | 
				
			||||||
    tf1=$($MKTEMP_CMD) tf2=$($MKTEMP_CMD)
 | 
					    tf1=$($MKTEMP_CMD) tf2=$($MKTEMP_CMD)
 | 
				
			||||||
    $CURL_CMD --fail -o "$tf1" --stderr "$tf2" $OPTS -XGET -s "$url"
 | 
					    $CURL_CMD --fail -o "$tf1" --stderr "$tf2" $OPTS -XGET -s "$url"
 | 
				
			||||||
@@ -269,7 +269,7 @@ checkFile() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
process() {
 | 
					process() {
 | 
				
			||||||
    file="$(realpath $1)"
 | 
					    file=$(realpath "$1")
 | 
				
			||||||
    dir="$2"
 | 
					    dir="$2"
 | 
				
			||||||
    info "---- Processing $file ----------"
 | 
					    info "---- Processing $file ----------"
 | 
				
			||||||
    declare -i curlrc=0
 | 
					    declare -i curlrc=0
 | 
				
			||||||
@@ -340,11 +340,11 @@ else
 | 
				
			|||||||
    if [ "$recursive" = "y" ]; then
 | 
					    if [ "$recursive" = "y" ]; then
 | 
				
			||||||
        REC="-r"
 | 
					        REC="-r"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    $INOTIFY_CMD $REC -m "${watchdir[@]}" -e close_write -e moved_to |
 | 
					    $INOTIFY_CMD $REC -m --format '%w%f' -e close_write -e moved_to "${watchdir[@]}" |
 | 
				
			||||||
        while read path action file; do
 | 
					        while read pathfile; do
 | 
				
			||||||
            dir=$(findDir "$path")
 | 
					            dir=$(findDir "$pathfile")
 | 
				
			||||||
            trace "The file '$file' appeared in directory '$path' below '$dir' via '$action'"
 | 
					            trace "The file '$pathfile' appeared below '$dir'"
 | 
				
			||||||
            sleep 1
 | 
					            sleep 1
 | 
				
			||||||
            process "$(realpath "$path$file")" "$dir"
 | 
					            process "$(realpath "$pathfile")" "$dir"
 | 
				
			||||||
        done
 | 
					        done
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user