summaryrefslogtreecommitdiff
path: root/freefilesync/ffs_sftp.patch
blob: afc8f07396af9114845421b2e386fa7647907b63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Source: <none>
Author: B Stack
Message: In FreeFileSync 10.16, upstream uses a higher version of libcurl than what is available for most distros. This change will probably break ftp usage and any such breakage should be reported to this patch author so that he can actually go package the latest version of libcurl for the affected distro instead of being lazy and basically breaking stuff just to compile.
Date: 2019-09-17T13:46:28Z

Source: <none>
Author: B Stack
Message: The upstream author observed that some of the values he uses are not in the libssh2 public headers. I don't know where he uses them from, but I had to replace them here to get this to compile.
Date: 2019-02-11T12:15:59Z
https://github.com/libssh2/libssh2/issues/90
diff -x '*.swp' -x '.git*' -Naur 10.16-0/FreeFileSync/Source/afs/ftp.cpp 10.16-1/FreeFileSync/Source/afs/ftp.cpp
--- 10.16-0/FreeFileSync/Source/afs/ftp.cpp	2019-09-17 07:56:37.351051558 -0400
+++ 10.16-1/FreeFileSync/Source/afs/ftp.cpp	2019-09-17 09:07:42.581456870 -0400
@@ -543,7 +543,7 @@
         ZEN_ON_SCOPE_EXIT(::curl_slist_free_all(quote));
         quote = ::curl_slist_append(quote, ftpCmd.c_str());
 
-        return perform(AfsPath(), true /*isDir*/, CURLFTPMETHOD_FULLPATH, //really avoid needless CWDs unlike buggy(!) CURLFTPMETHOD_NOCWD
+        return perform(AfsPath(), true /*isDir*/, CURLFTPMETHOD_LAST, //really avoid needless CWDs unlike buggy(!) CURLFTPMETHOD_NOCWD
         {
             { CURLOPT_NOBODY, 1L },
             { CURLOPT_QUOTE, quote },
@@ -665,7 +665,7 @@
         }
 
         /*  1. FFS CURLFTPMETHOD_NOCWD is buggy (see comment FtpSession::perform()) => must use absolute, not home-relative paths!
-            2. Support CURLFTPMETHOD_FULLPATH                                       => must use absolute, not home-relative paths!
+            2. Support CURLFTPMETHOD_LAST                                       => must use absolute, not home-relative paths!
             3. Some FTP servers distinguish between user-home- and root-relative paths! e.g. FreeNAS: https://freefilesync.org/forum/viewtopic.php?t=6129
                 => use root-relative paths (= same as expected by CURLOPT_QUOTE) https://curl.haxx.se/docs/faq.html#How_do_I_list_the_root_dir_of_an
                 => use // because /%2f had bugs (but they should be fixed: https://github.com/curl/curl/pull/4348)
@@ -1021,7 +1021,7 @@
                     }();
 
                     if (!pathHasWildcards)
-                        pathMethod = CURLFTPMETHOD_FULLPATH; //16% faster traversal compared to CURLFTPMETHOD_SINGLECWD (35% faster than CURLFTPMETHOD_MULTICWD)
+                        pathMethod = CURLFTPMETHOD_LAST; //16% faster traversal compared to CURLFTPMETHOD_SINGLECWD (35% faster than CURLFTPMETHOD_MULTICWD)
                 }
                 //else: use "LIST" + CURLFTPMETHOD_SINGLECWD
                 //caveat: let's better not use LIST parameters: https://cr.yp.to/ftp/list.html
@@ -1591,7 +1591,7 @@
     {
         accessFtpSession(login, [&](FtpSession& session) //throw SysError
         {
-            session.perform(afsFilePath, false /*isDir*/, CURLFTPMETHOD_FULLPATH, //are there any servers that require CURLFTPMETHOD_SINGLECWD? let's find out
+            session.perform(afsFilePath, false /*isDir*/, CURLFTPMETHOD_LAST, //are there any servers that require CURLFTPMETHOD_SINGLECWD? let's find out
             {
                 { CURLOPT_WRITEDATA, &onBytesReceived },
                 { CURLOPT_WRITEFUNCTION, onBytesReceivedWrapper },
@@ -1657,7 +1657,7 @@
 
                 //optimize fail-safe copy with RNFR/RNTO as CURLOPT_POSTQUOTE? -> even slightly *slower* than RNFR/RNTO as additional curl_easy_perform()
             */
-            session.perform(afsFilePath, false /*isDir*/, CURLFTPMETHOD_FULLPATH, //are there any servers that require CURLFTPMETHOD_SINGLECWD? let's find out
+            session.perform(afsFilePath, false /*isDir*/, CURLFTPMETHOD_LAST, //are there any servers that require CURLFTPMETHOD_SINGLECWD? let's find out
             {
                 { CURLOPT_UPLOAD, 1L },
                 { CURLOPT_READDATA, &getBytesToSend },
@@ -2126,7 +2126,7 @@
                 quote = ::curl_slist_append(quote, ("RNFR " + session.getServerRelPathInternal(pathFrom,       login_.timeoutSec)).c_str()); //throw SysError
                 quote = ::curl_slist_append(quote, ("RNTO " + session.getServerRelPathInternal(pathTo.afsPath, login_.timeoutSec)).c_str()); //
 
-                session.perform(AfsPath(), true /*isDir*/, CURLFTPMETHOD_FULLPATH, //really avoid needless CWDs unlike buggy(!) CURLFTPMETHOD_NOCWD
+                session.perform(AfsPath(), true /*isDir*/, CURLFTPMETHOD_LAST, //really avoid needless CWDs unlike buggy(!) CURLFTPMETHOD_NOCWD
                 {
                     { CURLOPT_NOBODY, 1L },
                     { CURLOPT_QUOTE, quote },
diff -x '*.orig' -x '*.swp' -x '*.rej' -Naur 10.9-0/FreeFileSync/Source/afs/sftp.cpp 10.9-1/FreeFileSync/Source/afs/sftp.cpp
--- 10.9-0/FreeFileSync/Source/afs/sftp.cpp  2019-02-10 16:42:29.139040980 -0500
+++ 10.9-1/FreeFileSync/Source/afs/sftp.cpp  2019-02-10 21:28:00.030732089 -0500
@@ -56,9 +56,10 @@

 //attention: if operation fails due to time out, e.g. file copy, the cleanup code may hang, too => total delay = 2 x time out interval

-const size_t SFTP_OPTIMAL_BLOCK_SIZE_READ  = 4 * MAX_SFTP_READ_SIZE;     //https://github.com/libssh2/libssh2/issues/90
-const size_t SFTP_OPTIMAL_BLOCK_SIZE_WRITE = 4 * MAX_SFTP_OUTGOING_SIZE; //
-static_assert(MAX_SFTP_READ_SIZE == 30000 && MAX_SFTP_OUTGOING_SIZE == 30000, "reevaluate optimal block sizes if these constants change!");
+// these values are all manually derived from https://github.com/libssh2/libssh2/blob/master/src/sftp.h which for some weak reason are not included in the libssh2-devel headers.
+const size_t SFTP_OPTIMAL_BLOCK_SIZE_READ  = 4 * 30000;     //https://github.com/libssh2/libssh2/issues/90
+const size_t SFTP_OPTIMAL_BLOCK_SIZE_WRITE = 4 * 30000; //
+//static_assert(MAX_SFTP_READ_SIZE == 30000 && MAX_SFTP_OUTGOING_SIZE == 30000, "reevaluate optimal block sizes if these constants change!");
 /*
 Perf Test, Sourceforge frs, SFTP upload, compressed 25 MB test file:

bgstack15