Skip to content

Commit

Permalink
fix error in rclone download. Add tests to run in compiled mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMaul committed Aug 24, 2022
1 parent 8b5cd70 commit 8f8aa09
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Project/Sources/Classes/FileTransfer_rclone.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ Function upload($sourcepath : Text; $targetpath : Text)->$success : Object
ASSERT:C1129($targetpath#""; "target path must not be empty")
$url:="copyto "+This:C1470._wrapLocal($sourcepath)+" "+This:C1470._wrapRemote($targetpath)
$success:=This:C1470._runWorker($url)
If (($success.data#"") & ($success.data#"Transferred@"))
If (($success.data#"") & ($success.data="@error@"))
$success.success:=False:C215
$success.error:=$success.data
End if

Function download($sourcepath : Text; $targetpath : Text)->$success : Object
ASSERT:C1129($sourcepath#""; "source path must not be empty")
ASSERT:C1129($targetpath#""; "target path must not be empty")
$url:="copyto "+This:C1470._wrapRemote($targetpath)+" "+This:C1470._wrapLocal($targetpath)
$url:="copyto "+This:C1470._wrapRemote($sourcepath)+" "+This:C1470._wrapLocal($targetpath)
$success:=This:C1470._runWorker($url)
If (($success.data#"") & ($success.data#"Transferred@"))
If (($success.data#"") & ($success.data="@error@"))
$success.success:=False:C215
$success.error:=$success.data
End if
Expand All @@ -58,7 +58,7 @@ Function syncUp($sourcepath : Text; $targetpath : Text)->$success : Object
ASSERT:C1129($targetpath#""; "target path must not be empty")
$url:="sync "+This:C1470._wrapLocal($sourcepath)+" "+This:C1470._wrapRemote($targetpath)
$success:=This:C1470._runWorker($url)
If (($success.data#"") & ($success.data#"Transferred@"))
If (($success.data#"") & ($success.data="@error@"))
$success.success:=False:C215
$success.error:=$success.data
End if
Expand All @@ -68,7 +68,7 @@ Function syncDown($sourcepath : Text; $targetpath : Text)->$success : Object
ASSERT:C1129($targetpath#""; "target path must not be empty")
$url:="sync "+This:C1470._wrapRemote($sourcepath)+" "+This:C1470._wrapLocal($targetpath)
$success:=This:C1470._runWorker($url)
If (($success.data#"") & ($success.data#"Transferred@"))
If (($success.data#"") & ($success.data="@error@"))
$success.success:=False:C215
$success.error:=$success.data
End if
Expand Down
64 changes: 64 additions & 0 deletions Project/Sources/Methods/test.4dm
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
//%attributes = {}
var $ftp : cs:C1710.FileTransfer_curl
$ftp:=cs:C1710.FileTransfer_curl.new("download.4d.com"; ""; ""; "https")

$progressid:="Download 4D.dmg"
$checkstop:=New shared object:C1526("stop"; False:C215)
$ftp.enableStopButton($checkstop)
$ftp.useCallback(Formula:C1597(ProgressCallback); $progressid)

$source:="/Products/4D_v19R5/Installers/4D_v19_R5_Mac.dmg"
$target:=System folder:C487(Desktop:K41:16)+"4d.dmg"
$target:=Convert path system to POSIX:C1106($target)
$ftp.setCurlPrefix("--location") // follow 301 or 302
$result:=$ftp.download($source; $target)

// did user canceled?
If ($checkstop.stop=True:C214)
// user canceled!!
Else
If ($result.success)
$answer:=$result.data
ALERT:C41("HTTP Download: "+$answer)
End if
End if


$ftp:=cs:C1710.FileTransfer_rclone.new("gdrive")
$path:="/users/thomas/Desktop/rclone-v1.59.1-osx-arm64/rclone"
$ftp.setPath($path)
$result:=$ftp.getDirectoryListing("/")
If ($result.success)
$list:=$result.list
$text:=JSON Stringify:C1217($list)
ALERT:C41("drive directory "+$text)
SET TEXT TO PASTEBOARD:C523($text)
Else
ALERT:C41("error")
End if


$ftp:=cs:C1710.FileTransfer_rclone.new("gdrive")
$path:="/users/thomas/Desktop/rclone-v1.59.1-osx-arm64/rclone"
$ftp.setPath($path)
$progressid:="Download zipg"
$checkstop:=New shared object:C1526("stop"; False:C215)
$ftp.enableStopButton($checkstop)
$ftp.useCallback(Formula:C1597(ProgressCallback); $progressid)

$source:="/16-10_CookieBaseWebAuth.zip"
$target:=System folder:C487(Desktop:K41:16)+"test.zip"
$target:=Convert path system to POSIX:C1106($target)
$result:=$ftp.download($source; $target)

// did user canceled?
If ($checkstop.stop=True:C214)
// user canceled!!
Else
If ($result.success)
$answer:=$result.data
ALERT:C41("gdrive Download: "+$answer)
Else
ALERT:C41("error")
End if

End if
2 changes: 1 addition & 1 deletion Project/Sources/Methods/test_curl.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $credentialspath:=Get 4D folder:C485(Database folder:K5:14)
$folder:=Folder:C1567($credentialspath; fk platform path:K87:2)
$credentialsfile:=$folder.parent.file("credentials.txt").getText()
$credentials:=JSON Parse:C1218($credentialsfile)
If (True:C214)
If (False:C215)
$credentials.url:="192.168.10.54:3421"
// $credentials.user:="myself"
// $credentials.password:="notmypass"
Expand Down
2 changes: 1 addition & 1 deletion Project/Sources/Methods/test_curl_http.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ If (True:C214) // download with progress, stop button
$ftp.enableStopButton($checkstop)
$ftp.useCallback(Formula:C1597(ProgressCallback); $progressid)

$source:="/Products/4D_v19R3/Installers/4D_v19_R3_Mac.dmg"
$source:="/Products/4D_v19R5/Installers/4D_v19_R5_Mac.dmg"
$target:=System folder:C487(Desktop:K41:16)+"4d.dmg"
$target:=Convert path system to POSIX:C1106($target)
$ftp.setCurlPrefix("--location") // follow 301 or 302
Expand Down

0 comments on commit 8f8aa09

Please sign in to comment.