Skip to content

Commit 495d53b

Browse files
committed
Don't try to copy parent directory entry
1 parent 3946374 commit 495d53b

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/NetBox/WinSCPFileSystem.cpp

+20-12
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,10 @@ int32_t TWinSCPFileSystem::GetFilesEx(TObjectList * PanelItems, bool Move,
25452545
FFileList.reset(CreateFileList(PanelItems, osRemote));
25462546
try__finally
25472547
{
2548-
Result = GetFilesRemote(PanelItems, Move, DestPath, OpMode);
2548+
if (FFileList->GetCount() > 0)
2549+
{
2550+
Result = GetFilesRemote(PanelItems, Move, DestPath, OpMode);
2551+
}
25492552
}
25502553
__finally
25512554
{
@@ -2559,8 +2562,12 @@ int32_t TWinSCPFileSystem::GetFilesEx(TObjectList * PanelItems, bool Move,
25592562
UnicodeString Prompt;
25602563
if (PanelItems->GetCount() == 1)
25612564
{
2562-
Prompt = FORMAT(GetMsg(NB_EXPORT_SESSION_PROMPT),
2563-
PanelItems->GetAs<TFarPanelItem>(0)->GetFileName());
2565+
auto FileName = PanelItems->GetAs<TFarPanelItem>(0)->GetFileName();
2566+
if (FileName == PARENTDIRECTORY)
2567+
{
2568+
return Result;
2569+
}
2570+
Prompt = FORMAT(GetMsg(NB_EXPORT_SESSION_PROMPT), FileName);
25642571
}
25652572
else
25662573
{
@@ -2779,7 +2786,7 @@ int32_t TWinSCPFileSystem::UploadFiles(bool Move, OPERATION_MODES OpMode, bool E
27792786

27802787
int32_t TWinSCPFileSystem::PutFilesEx(TObjectList * PanelItems, bool Move, OPERATION_MODES OpMode)
27812788
{
2782-
int32_t Result;
2789+
int32_t Result = -1;
27832790
if (Connected())
27842791
{
27852792
FFileList.reset(CreateFileList(PanelItems, osLocal));
@@ -2788,6 +2795,10 @@ int32_t TWinSCPFileSystem::PutFilesEx(TObjectList * PanelItems, bool Move, OPERA
27882795
FPanelItems = nullptr;
27892796
FFileList.reset();
27902797
};
2798+
if (FFileList->GetCount() == 0)
2799+
{
2800+
return Result;
2801+
}
27912802
FPanelItems = PanelItems;
27922803

27932804
// if file is saved under different name, FAR tries to upload original file,
@@ -2828,21 +2839,18 @@ int32_t TWinSCPFileSystem::PutFilesEx(TObjectList * PanelItems, bool Move, OPERA
28282839
FTerminal->SetCurrentDirectory(CurrentDirectory);
28292840
}
28302841
}
2831-
else if (IsSessionList())
2842+
else if (IsSessionList() && PanelItems)
28322843
{
2833-
if (!ImportSessions(PanelItems, Move, OpMode))
2844+
if (PanelItems->GetCount() == 1 &&
2845+
PanelItems->GetAs<TFarPanelItem>(0)->GetFileName() == PARENTDIRECTORY)
28342846
{
2835-
Result = -1;
2847+
return Result;
28362848
}
2837-
else
2849+
if (ImportSessions(PanelItems, Move, OpMode))
28382850
{
28392851
Result = 1;
28402852
}
28412853
}
2842-
else
2843-
{
2844-
Result = -1;
2845-
}
28462854
return Result;
28472855
}
28482856

0 commit comments

Comments
 (0)