|
@@ -1317,19 +1317,25 @@ bool CurlFtp::setSftp(CURL* curl)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+ * @brief 检查FTP文件夹是否存在,注意,传入的文件夹最后一定要带/,否则会检查的是文件
|
|
|
+ *
|
|
|
+ * @param dir
|
|
|
+ * @return true
|
|
|
+ * @return false
|
|
|
+ */
|
|
|
bool CurlFtp::checkFtpDirExist(const std::string& dir)
|
|
|
{
|
|
|
|
|
|
auto dirTmp = checkDirPath(dir);
|
|
|
resetCurl(m_curl);
|
|
|
- std::string ftpUrl = m_ftpUrl + dir;
|
|
|
+ std::string ftpUrl = m_ftpUrl + dirTmp;
|
|
|
curl_easy_setopt(m_curl, CURLOPT_URL, ftpUrl.c_str());
|
|
|
curl_easy_setopt(m_curl, CURLOPT_USERNAME, m_username.c_str());
|
|
|
curl_easy_setopt(m_curl, CURLOPT_PASSWORD, m_password.c_str());
|
|
|
|
|
|
curl_easy_setopt(m_curl, CURLOPT_NOBODY, 1L);
|
|
|
- curl_easy_setopt(m_curl, CURLOPT_HEADER, 1L);
|
|
|
+
|
|
|
|
|
|
|
|
|
setSftp(m_curl);
|
|
@@ -1348,23 +1354,15 @@ bool CurlFtp::checkFtpDirExist(const std::string& dir)
|
|
|
{
|
|
|
result = false;
|
|
|
}
|
|
|
- else if(res != CURLE_OK)
|
|
|
+ else if(res == CURLE_OK)
|
|
|
{
|
|
|
-
|
|
|
- result = false;
|
|
|
- }
|
|
|
- else
|
|
|
+ result = true;
|
|
|
+ } else
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ SPDLOG_ERROR("Check remote dir error, error code: {} ,{}", (int)res, curl_easy_strerror(res));
|
|
|
+ result = false;
|
|
|
}
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|