From 5c7c9f997e8d1d5e11ae34a7103cbe5bbedf2d24 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 10 Jun 2022 16:13:34 +0200 Subject: [PATCH] lib/libnetwork.lib.in: curl.ftp_command: autodetected webdav support for mkdir, rename-file and delete --- lib/libnetwork.lib.in | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/lib/libnetwork.lib.in b/lib/libnetwork.lib.in index f275320..d0ce58d 100644 --- a/lib/libnetwork.lib.in +++ b/lib/libnetwork.lib.in @@ -789,6 +789,8 @@ action:,directory:,rename-from:,rename-to:,delete:,ftp-passive \ [ "$ftp_passive" ] && options="$options $ftp_passive" + [ "${1:0:4}" == "http" ] && http_mode=1 + # NOTE: see RFC959 for the sintax of the 'quote' commands # curl --ftp-pasv --user user:password \ # -Q "MKD /devel/old/prova.dir" \ @@ -798,21 +800,34 @@ action:,directory:,rename-from:,rename-to:,delete:,ftp-passive \ mkdir) [ "$directory" ] || notify.error $"\ (bug)"" -- $FUNCNAME: "$"missing mandatory arg"" (--directory)" - notify.debug "\ -curl $options --user \"***:***\" --quote \"MKD $directory\" $1" - curl $options --user "$user" --quote "MKD $directory" $1 &>/dev/null + if [ "$http_mode" == "1" ]; then + notify.debug "\ +curl $options --user \"***:***\" -X MKCOL $1${directory}/" + curl $options --user "$user" -X MKCOL $1${directory}/ &>/dev/null + else + notify.debug "\ +curl $options --user \"***:***\" --quote \"MKD $directory\" $1" + curl $options --user "$user" --quote "MKD $directory" $1 &>/dev/null + fi ;; rename-file) [ "$fromfile" ] || notify.error $"\ (bug)"" -- $FUNCNAME: "$"missing mandatory arg"" (--rename-from)" [ "$tofile" ] || notify.error $"\ (bug)"" -- $FUNCNAME: "$"missing mandatory arg"" (--rename-to)" - notify.debug "curl $options --user \"***:***\"\ - --quote \"RNFR $fromfile\" --quote \"RNTO $tofile\" $1" - curl $options --user "$user" \ - --quote "RNFR $fromfile" --quote "RNTO $tofile" $1 &>/dev/null + if [ "$http_mode" == "1" ]; then + notify.debug "curl $options --user \"***:***\" -X MOVE\ + --header \"Destination:$1$tofile\" $1$fromfile" + curl $options --user "$user" -X MOVE \ + --header "Destination:$1$tofile" $1$fromfile &>/dev/null + else + notify.debug "curl $options --user \"***:***\"\ + --quote \"RNFR $fromfile\" --quote \"RNTO $tofile\" $1" + curl $options --user "$user" \ + --quote "RNFR $fromfile" --quote "RNTO $tofile" $1 &>/dev/null + fi ;; delete) [ "$deletefile" ] || notify.error $"\ @@ -827,9 +842,15 @@ curl $options --user \"***:***\" --quote \"MKD $directory\" $1" # curl -v --ftp-pasv --user "$user" \ # --quote "DELE SRPMS.base/filename-0.0.1-1distro.src.rpm" \ # ftp://ftpaccounts.openmamba.org - notify.debug "\ + if [ "$http_mode" == "1" ]; then + notify.debug "\ +curl $options --user \"***:***\" -X DELETE $1$deletefile" + curl $options --user "$user" -X DELETE $1$deletefile &>/dev/null + else + notify.debug "\ curl $options --user \"***:***\" --quote \"DELE $deletefile\" $1" - curl $options --user "$user" --quote "DELE $deletefile" $1 &>/dev/null + curl $options --user "$user" --quote "DELE $deletefile" $1 &>/dev/null + fi ;; *) notify.error $"\ (bug)"" -- $FUNCNAME: "$"unknown action"": ($action)"