Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

修正 FileZilla 3 beta2 傳送目錄時, 不會建立空的目錄的問題
post by tommy @ 19 十月, 2006 15:50
我不確定這個是作者沒考慮到, 還是故意這樣子處理的. 當 FileZilla 3 在上下傳目錄時, 如果目錄下頭沒有任何檔案, 則那個目錄並不會被處理 (建立). 而這個動作在 2.x 的版本時, 是會建立這樣的目錄的.

這個 patch 可以修正這個問題:

diff -Nur src.orig/engine/ftpcontrolsocket.cpp src/engine/ftpcontrolsocket.cpp
--- src.orig/engine/ftpcontrolsocket.cpp Wed Oct 18 21:24:30 2006
+++ src/engine/ftpcontrolsocket.cpp Thu Oct 19 15:27:30 2006
@@ -1505,6 +1505,15 @@
// Be quiet
wxLogNull nullLog;

+ // twu2, create an empty directory only
+ if (pData->localFile.Last() == wxFileName::GetPathSeparator()) {
+ // create dir
+ wxFileName fn(pData->localFile);
+ wxFileName::Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL);
+ ResetOperation(FZ_REPLY_OK);
+ return FZ_REPLY_OK;
+ }
+
wxFileOffset startOffset;
if (pData->resume)
{
@@ -1570,6 +1579,13 @@
}
else
{
+ // twu2, create an empty directory only
+ if (pData->localFile.Last() == wxFileName::GetPathSeparator()) {
+ // already created
+ ResetOperation(FZ_REPLY_OK);
+ return FZ_REPLY_OK;
+ }
+
if (!pFile->Open(pData->localFile, wxFile::read))
{
delete pFile;
diff -Nur src.orig/engine/sftpcontrolsocket.cpp src/engine/sftpcontrolsocket.cpp
--- src.orig/engine/sftpcontrolsocket.cpp Wed Oct 18 21:24:30 2006
+++ src/engine/sftpcontrolsocket.cpp Thu Oct 19 15:28:40 2006
@@ -1392,6 +1392,12 @@
wxFileName fn(pData->localFile);
wxFileName::Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL);
}
+ // twu2, create an empty directory only
+ if (pData->localFile.Last() == wxFileName::GetPathSeparator()) {
+ // already created
+ ResetOperation(FZ_REPLY_OK);
+ return FZ_REPLY_OK;
+ }

InitTransferStatus(pData->remoteFileSize, pData->resume ? pData->localFileSize : 0);
cmd += _T("get ");
@@ -1400,6 +1406,12 @@
}
else
{
+ // twu2, create an empty directory only
+ if (pData->localFile.Last() == wxFileName::GetPathSeparator()) {
+ // already created
+ ResetOperation(FZ_REPLY_OK);
+ return FZ_REPLY_OK;
+ }
InitTransferStatus(pData->localFileSize, pData->resume ? pData->remoteFileSize : 0);
cmd += _T("put ");
cmd += QuoteFilename(pData->localFile) + _T(" ");
diff -Nur src.orig/interface/QueueView.cpp src/interface/QueueView.cpp
--- src.orig/interface/QueueView.cpp Sun Oct 8 21:25:13 2006
+++ src/interface/QueueView.cpp Thu Oct 19 15:27:30 2006
@@ -97,6 +97,29 @@
m_pFolderItem->m_currentRemotePath = pair.remotePath;

found = m_pFolderItem->m_pDir->GetFirst(&file);
+ // twu2, empty directory
+ if (!found) {
+ // add empty directory
+ wxFileName fn(pair.localPath);
+ t_newEntry entry;
+ entry.localFile = pair.localPath + wxFileName::GetPathSeparator();
+ entry.remoteFile = fn.GetName();
+ entry.remotePath = m_pFolderItem->m_currentRemotePath;
+ entry.size = 0;
+
+ bool send = false;
+ m_sync.Enter();;
+ if (!m_entryList.size())
+ send = true;
+ m_entryList.push_back(entry);
+ m_sync.Leave();
+
+ if (send)
+ {
+ wxCommandEvent evt(fzEVT_FOLDERTHREAD_FILES, wxID_ANY);
+ wxPostEvent(m_pOwner, evt);
+ }
+ }
}
else
found = false;
diff -Nur src.orig/interface/RemoteListView.cpp src/interface/RemoteListView.cpp
--- src.orig/interface/RemoteListView.cpp Thu Oct 19 15:10:09 2006
+++ src/interface/RemoteListView.cpp Thu Oct 19 15:27:30 2006
@@ -738,6 +738,8 @@
{
wxFileName fn = wxFileName(m_pState->GetLocalDir(), _T(""));
fn.AppendDir(name);
+ // twu2, add directory also
+ m_pQueue->QueueFile(event.GetId() == XRCID("ID_ADDTOQUEUE"), true, fn.GetFullPath(), name, m_pDirectoryListing->path, *pServer, 0);
CServerPath remotePath = m_pDirectoryListing->path;
if (remotePath.AddSegment(name))
{
@@ -955,6 +957,9 @@
m_dirsToVisit.push_back(dirToVisit);
if (m_operationMode == recursive_delete)
m_dirsToDelete.push_front(dirToVisit);
+ // twu2, add directory also
+ if (m_operationMode == recursive_addtoqueue || m_operationMode == recursive_download)
+ m_pQueue->QueueFile(m_operationMode == recursive_addtoqueue, true, fn.GetFullPath(), entry.name, m_pDirectoryListing->path, *pServer, 0);
}
else
{
 

patch 可以在這兒抓取: http://www.teatime.com.tw/~tommy/mypatch/filezilla3_beta2_transfer_empty_dir.patch 

如果需要產生的 Windows 執行檔, 可以在前幾天那個 sftp UTF-8 patch 的文章下載. 


2006/10/20: 

這個 patch 今天被作者 reject 了. (說的也沒錯, 本來就是一個 ugly 的解法.... 不過, 在沒有其他的解決方案之前, 我不覺得我的方法有什麼不好.)  作者的回覆有點看不太懂, 等明天更新到最新的 CVS 之後, 看看作者所說的那些動作是什麼吧. 看了一下 CVS 的內容, 應該是只有在下載的時候, 會在 local 端建立空的目錄. 而目前看起來, 如果是上傳的話, 應該不會在遠端建立空的目錄. 希望只是還沒寫完, 而不是就不支援這樣的功能了. 


2006/10/21: 

作者似乎會有另外的實作方式, 我是不怎麼喜歡目前作者使用的解決方案, 在沒有看到新的解決方案前, 看來還是自己使用這份 patch 好了. 


2006/10/22: 

作者今天在 CVS 中實作了他的解決方案, 所以這個問題應該在今天之後的 CVS 中都可以獲得解決. 


2006/10/25: 

剛剛發現, 作者的改法, 在 download 時運作正常, 但是 upload 時會發生錯誤. 已反應給作者解決中. 


2006/10/26: 

今天的 CVS 已經修正這個問題, 剛剛試著 update 到 CVS 的版本後, 編譯一個執行檔來測看看, 目前看起來一切正常.

 

Del.icio.us Furl HEMiDEMi Technorati MyShare
迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

Bad Behavior 已經阻擋了 92 個過去 7 天試圖闖關的垃圾迴響與引用。
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS