From c527fc3b021c6d7ef35ed58fcdb36c6a502e25fb Mon Sep 17 00:00:00 2001 From: ScriptFanix Date: Fri, 16 Jan 2026 02:31:34 +0100 Subject: [PATCH] Resolve "Store dest filename relative" --- lib/copy/matching | 53 +++++++++++++++++++++++--------------------- lib/files/getDestDir | 2 +- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/lib/copy/matching b/lib/copy/matching index b0f6516..73087a0 100644 --- a/lib/copy/matching +++ b/lib/copy/matching @@ -1,33 +1,36 @@ #!/bin/bash copyFiles_matching() { - extension="${filename##*.}" + local extension="${filename##*.}" + if \ cp -al \ "$sourcepath/$filename" \ - "$destdir/$destfile.$extension" \ + "${destinationpath[$destination]}/$destdir/$destfile.$extension" \ 2>/dev/null \ || cp -a \ "$sourcepath/$filename" \ - "$destdir/$destfile.$extension" - echo \ - "UPDATE destination_files" \ - "SET filename=" \ - "\"${destdir//\"/\"\"}/${destfile//\"/\"\"}.$extension\"," \ - " last_change=(" \ - " SELECT last_change" \ - " FROM source_files" \ - " WHERE id=$fileid" \ - " )," \ - " old_filename=(" \ - " SELECT filename" \ - " FROM destination_files" \ - " WHERE id=$destfileid" \ - " )," \ - " rename_pattern=" \ -"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\","\ - " fat32compat=" \ - "${destinationfat32compat["$destination"]}," \ - " ascii=${destinationascii["$destination"]}" \ - "WHERE id=$destfileid;" \ - >&3 - (( ++copies )) + "${destinationpath[$destination]}/$destdir/$destfile.$extension" + then + echo \ + "UPDATE destination_files" \ + "SET filename=" \ + "\"${destdir//\"/\"\"}/${destfile//\"/\"\"}.$extension\"," \ + " last_change=(" \ + " SELECT last_change" \ + " FROM source_files" \ + " WHERE id=$fileid" \ + " )," \ + " old_filename=(" \ + " SELECT filename" \ + " FROM destination_files" \ + " WHERE id=$destfileid" \ + " )," \ + " rename_pattern=" \ + "\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\","\ + " fat32compat=" \ + "${destinationfat32compat["$destination"]}," \ + " ascii=${destinationascii["$destination"]}"\ + "WHERE id=$destfileid;" \ + >&3 + (( ++copies )) + fi } diff --git a/lib/files/getDestDir b/lib/files/getDestDir index 79177e0..cb9cd89 100644 --- a/lib/files/getDestDir +++ b/lib/files/getDestDir @@ -98,7 +98,7 @@ getDestDir() { part=${part#*/} done fi - if ! [ -d "$destdir" ] + if ! [ -d "${destinationpath[$destination]}/$destdir" ] then mkdir -p "${destinationpath[$destination]}/$destdir" fi