Skip to content

Commit 8f8aa09

Browse files
committed
fix error in rclone download. Add tests to run in compiled mode
1 parent 8b5cd70 commit 8f8aa09

File tree

4 files changed

+71
-7
lines changed

4 files changed

+71
-7
lines changed

Project/Sources/Classes/FileTransfer_rclone.4dm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ Function upload($sourcepath : Text; $targetpath : Text)->$success : Object
3838
ASSERT:C1129($targetpath#""; "target path must not be empty")
3939
$url:="copyto "+This:C1470._wrapLocal($sourcepath)+" "+This:C1470._wrapRemote($targetpath)
4040
$success:=This:C1470._runWorker($url)
41-
If (($success.data#"") & ($success.data#"Transferred@"))
41+
If (($success.data#"") & ($success.data="@error@"))
4242
$success.success:=False:C215
4343
$success.error:=$success.data
4444
End if
4545

4646
Function download($sourcepath : Text; $targetpath : Text)->$success : Object
4747
ASSERT:C1129($sourcepath#""; "source path must not be empty")
4848
ASSERT:C1129($targetpath#""; "target path must not be empty")
49-
$url:="copyto "+This:C1470._wrapRemote($targetpath)+" "+This:C1470._wrapLocal($targetpath)
49+
$url:="copyto "+This:C1470._wrapRemote($sourcepath)+" "+This:C1470._wrapLocal($targetpath)
5050
$success:=This:C1470._runWorker($url)
51-
If (($success.data#"") & ($success.data#"Transferred@"))
51+
If (($success.data#"") & ($success.data="@error@"))
5252
$success.success:=False:C215
5353
$success.error:=$success.data
5454
End if
@@ -58,7 +58,7 @@ Function syncUp($sourcepath : Text; $targetpath : Text)->$success : Object
5858
ASSERT:C1129($targetpath#""; "target path must not be empty")
5959
$url:="sync "+This:C1470._wrapLocal($sourcepath)+" "+This:C1470._wrapRemote($targetpath)
6060
$success:=This:C1470._runWorker($url)
61-
If (($success.data#"") & ($success.data#"Transferred@"))
61+
If (($success.data#"") & ($success.data="@error@"))
6262
$success.success:=False:C215
6363
$success.error:=$success.data
6464
End if
@@ -68,7 +68,7 @@ Function syncDown($sourcepath : Text; $targetpath : Text)->$success : Object
6868
ASSERT:C1129($targetpath#""; "target path must not be empty")
6969
$url:="sync "+This:C1470._wrapRemote($sourcepath)+" "+This:C1470._wrapLocal($targetpath)
7070
$success:=This:C1470._runWorker($url)
71-
If (($success.data#"") & ($success.data#"Transferred@"))
71+
If (($success.data#"") & ($success.data="@error@"))
7272
$success.success:=False:C215
7373
$success.error:=$success.data
7474
End if

Project/Sources/Methods/test.4dm

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,65 @@
11
//%attributes = {}
2+
var $ftp : cs:C1710.FileTransfer_curl
3+
$ftp:=cs:C1710.FileTransfer_curl.new("download.4d.com"; ""; ""; "https")
4+
5+
$progressid:="Download 4D.dmg"
6+
$checkstop:=New shared object:C1526("stop"; False:C215)
7+
$ftp.enableStopButton($checkstop)
8+
$ftp.useCallback(Formula:C1597(ProgressCallback); $progressid)
9+
10+
$source:="/Products/4D_v19R5/Installers/4D_v19_R5_Mac.dmg"
11+
$target:=System folder:C487(Desktop:K41:16)+"4d.dmg"
12+
$target:=Convert path system to POSIX:C1106($target)
13+
$ftp.setCurlPrefix("--location") // follow 301 or 302
14+
$result:=$ftp.download($source; $target)
15+
16+
// did user canceled?
17+
If ($checkstop.stop=True:C214)
18+
// user canceled!!
19+
Else
20+
If ($result.success)
21+
$answer:=$result.data
22+
ALERT:C41("HTTP Download: "+$answer)
23+
End if
24+
End if
25+
26+
27+
$ftp:=cs:C1710.FileTransfer_rclone.new("gdrive")
28+
$path:="/users/thomas/Desktop/rclone-v1.59.1-osx-arm64/rclone"
29+
$ftp.setPath($path)
30+
$result:=$ftp.getDirectoryListing("/")
31+
If ($result.success)
32+
$list:=$result.list
33+
$text:=JSON Stringify:C1217($list)
34+
ALERT:C41("drive directory "+$text)
35+
SET TEXT TO PASTEBOARD:C523($text)
36+
Else
37+
ALERT:C41("error")
38+
End if
39+
40+
41+
$ftp:=cs:C1710.FileTransfer_rclone.new("gdrive")
42+
$path:="/users/thomas/Desktop/rclone-v1.59.1-osx-arm64/rclone"
43+
$ftp.setPath($path)
44+
$progressid:="Download zipg"
45+
$checkstop:=New shared object:C1526("stop"; False:C215)
46+
$ftp.enableStopButton($checkstop)
47+
$ftp.useCallback(Formula:C1597(ProgressCallback); $progressid)
48+
49+
$source:="/16-10_CookieBaseWebAuth.zip"
50+
$target:=System folder:C487(Desktop:K41:16)+"test.zip"
51+
$target:=Convert path system to POSIX:C1106($target)
52+
$result:=$ftp.download($source; $target)
53+
54+
// did user canceled?
55+
If ($checkstop.stop=True:C214)
56+
// user canceled!!
57+
Else
58+
If ($result.success)
59+
$answer:=$result.data
60+
ALERT:C41("gdrive Download: "+$answer)
61+
Else
62+
ALERT:C41("error")
63+
End if
64+
65+
End if

Project/Sources/Methods/test_curl.4dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $credentialspath:=Get 4D folder:C485(Database folder:K5:14)
77
$folder:=Folder:C1567($credentialspath; fk platform path:K87:2)
88
$credentialsfile:=$folder.parent.file("credentials.txt").getText()
99
$credentials:=JSON Parse:C1218($credentialsfile)
10-
If (True:C214)
10+
If (False:C215)
1111
$credentials.url:="192.168.10.54:3421"
1212
// $credentials.user:="myself"
1313
// $credentials.password:="notmypass"

Project/Sources/Methods/test_curl_http.4dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ If (True:C214) // download with progress, stop button
5454
$ftp.enableStopButton($checkstop)
5555
$ftp.useCallback(Formula:C1597(ProgressCallback); $progressid)
5656

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

0 commit comments

Comments
 (0)