1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

Bug 1922: Do not use a transfer via temporary file for files that would exceed system length limit with the temporary extension

https://winscp.net/tracker/1922

Source commit: f9016b757e70c4d7479abe4cc9b3ff1ad2878ed3
This commit is contained in:
Martin Prikryl
2020-11-09 10:11:04 +00:00
parent 6cf2f5d3c8
commit 7f1aaa1b1a
4 changed files with 21 additions and 11 deletions

View File

@@ -775,15 +775,24 @@ int __fastcall TCopyParamType::LocalFileAttrs(const TRights & Rights) const
return Result;
}
//---------------------------------------------------------------------------
bool __fastcall TCopyParamType::AllowResume(__int64 Size) const
bool __fastcall TCopyParamType::AllowResume(__int64 Size, const UnicodeString & FileName) const
{
switch (ResumeSupport)
bool Result;
if (FileName.Length() + UnicodeString(PARTIAL_EXT).Length() > 255) // it's a different limit than MAX_PATH
{
case rsOn: return true;
case rsOff: return false;
case rsSmart: return (Size >= ResumeThreshold);
default: DebugFail(); return false;
Result = false;
}
else
{
switch (ResumeSupport)
{
case rsOn: Result = true; break;
case rsOff: Result = false; break;
case rsSmart: Result = (Size >= ResumeThreshold); break;
default: DebugFail(); Result = false; break;
}
}
return Result;
}
//---------------------------------------------------------------------------
bool __fastcall TCopyParamType::AllowAnyTransfer() const

View File

@@ -100,7 +100,7 @@ public:
TRights __fastcall RemoteFileRights(int Attrs) const;
bool __fastcall UseAsciiTransfer(UnicodeString FileName, TOperationSide Side,
const TFileMasks::TParams & Params) const;
bool __fastcall AllowResume(__int64 Size) const;
bool __fastcall AllowResume(__int64 Size, const UnicodeString & FileName) const;
bool __fastcall ResumeTransfer(UnicodeString FileName) const;
UnicodeString __fastcall ValidLocalFileName(UnicodeString FileName) const;
UnicodeString __fastcall ValidLocalPath(UnicodeString Path) const;

View File

@@ -3669,9 +3669,10 @@ bool __fastcall TFTPFileSystem::HandleAsynchRequestOverwrite(
}
}
bool AllowResume = UserData.CopyParam->AllowResume(FileParams.SourceSize, UnicodeString());
bool AutoResume = UserData.AutoResume;
if (ConfirmOverwrite(SourceFullFileName, TargetFileName, OverwriteMode, OperationProgress,
(NoFileParams ? NULL : &FileParams), UserData.CopyParam, UserData.Params,
UserData.AutoResume && UserData.CopyParam->AllowResume(FileParams.SourceSize)))
(NoFileParams ? NULL : &FileParams), UserData.CopyParam, UserData.Params, AutoResume))
{
switch (OverwriteMode)
{

View File

@@ -4502,7 +4502,7 @@ void __fastcall TSFTPFileSystem::Source(
// should we check for interrupted transfer?
ResumeAllowed =
!OperationProgress->AsciiTransfer &&
CopyParam->AllowResume(OperationProgress->LocalSize) &&
CopyParam->AllowResume(OperationProgress->LocalSize, DestFileName) &&
IsCapable(fcRename) &&
!FTerminal->IsEncryptingFiles() &&
(CopyParam->OnTransferIn == NULL);
@@ -5260,7 +5260,7 @@ void __fastcall TSFTPFileSystem::Sink(
bool ResumeAllowed =
FLAGCLEAR(Params, cpTemporary) &&
!OperationProgress->AsciiTransfer &&
CopyParam->AllowResume(OperationProgress->TransferSize) &&
CopyParam->AllowResume(OperationProgress->TransferSize, DestFileName) &&
!FTerminal->IsEncryptingFiles() &&
(CopyParam->OnTransferOut == NULL);