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

No public writable fields in TFileOperationProgressType (in anticipation of shared progress for parallel transfers)

Source commit: c2adf6522c5c585d2e8df47285aa23c30da0fab8
This commit is contained in:
Martin Prikryl
2016-11-29 11:46:31 +00:00
parent f679d63fa5
commit ea01897e79
11 changed files with 221 additions and 184 deletions

View File

@@ -33,34 +33,36 @@ __fastcall TFileOperationProgressType::~TFileOperationProgressType()
void __fastcall TFileOperationProgressType::AssignButKeepSuspendState(const TFileOperationProgressType & Other)
{
TValueRestorer<unsigned int> SuspendTimeRestorer(FSuspendTime);
TValueRestorer<bool> SuspendedRestorer(Suspended);
TValueRestorer<bool> SuspendedRestorer(FSuspended);
*this = Other;
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::Clear()
{
FileName = L"";
AsciiTransfer = false;
Count = 0;
FFileName = L"";
FFullFileName = L"";
FDirectory = L"";
FAsciiTransfer = false;
FCount = 0;
FFilesFinished = 0;
StartTime = Now();
Suspended = false;
FStartTime = Now();
FSuspended = false;
FSuspendTime = 0;
InProgress = false;
FileInProgress = false;
TotalTransfered = 0;
TotalSkipped = 0;
TotalSize = 0;
SkippedSize = 0;
TotalSizeSet = false;
Operation = foNone;
Temp = false;
SkipToAll = false;
BatchOverwrite = boNo;
FInProgress = false;
FFileInProgress = false;
FTotalTransfered = 0;
FTotalSkipped = 0;
FTotalSize = 0;
FSkippedSize = 0;
FTotalSizeSet = false;
FOperation = foNone;
FTemp = false;
FSkipToAll = false;
FBatchOverwrite = boNo;
// to bypass check in ClearTransfer()
TransferSize = 0;
CPSLimit = 0;
FTransferSize = 0;
FCPSLimit = 0;
FTicks.clear();
FTotalTransferredThen.clear();
FCounterSet = false;
@@ -72,14 +74,14 @@ void __fastcall TFileOperationProgressType::ClearTransfer()
if ((TransferSize > 0) && (TransferedSize < TransferSize))
{
__int64 RemainingSize = (TransferSize - TransferedSize);
TotalSkipped += RemainingSize;
FTotalSkipped += RemainingSize;
}
LocalSize = 0;
TransferSize = 0;
LocallyUsed = 0;
SkippedSize = 0;
TransferedSize = 0;
TransferingFile = false;
FLocalSize = 0;
FTransferSize = 0;
FLocallyUsed = 0;
FSkippedSize = 0;
FTransferedSize = 0;
FTransferingFile = false;
FLastSecond = 0;
}
//---------------------------------------------------------------------------
@@ -94,14 +96,14 @@ void __fastcall TFileOperationProgressType::Start(TFileOperation AOperation,
const UnicodeString ADirectory, unsigned long ACPSLimit)
{
Clear();
Operation = AOperation;
Side = ASide;
Count = ACount;
InProgress = true;
Cancel = csContinue;
Directory = ADirectory;
Temp = ATemp;
CPSLimit = ACPSLimit;
FOperation = AOperation;
FSide = ASide;
FCount = ACount;
FInProgress = true;
FCancel = csContinue;
FDirectory = ADirectory;
FTemp = ATemp;
FCPSLimit = ACPSLimit;
try
{
DoProgress();
@@ -110,7 +112,7 @@ void __fastcall TFileOperationProgressType::Start(TFileOperation AOperation,
{
// connection can be lost during progress callbacks
ClearTransfer();
InProgress = false;
FInProgress = false;
throw;
}
}
@@ -125,14 +127,14 @@ void __fastcall TFileOperationProgressType::Stop()
// added to include remaining bytes to TotalSkipped, in case
// the progress happens to update before closing
ClearTransfer();
InProgress = false;
FInProgress = false;
DoProgress();
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::Suspend()
{
DebugAssert(!Suspended);
Suspended = true;
FSuspended = true;
FSuspendTime = GetTickCount();
DoProgress();
}
@@ -140,7 +142,7 @@ void __fastcall TFileOperationProgressType::Suspend()
void __fastcall TFileOperationProgressType::Resume()
{
DebugAssert(Suspended);
Suspended = false;
FSuspended = false;
// shift timestamps for CPS calculation in advance
// by the time the progress was suspended
@@ -221,7 +223,7 @@ void __fastcall TFileOperationProgressType::Finish(UnicodeString FileName,
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetFile(UnicodeString AFileName, bool AFileInProgress)
{
FullFileName = AFileName;
FFullFileName = AFileName;
if (Side == osRemote)
{
// historically set were passing filename-only for remote site operations,
@@ -229,8 +231,8 @@ void __fastcall TFileOperationProgressType::SetFile(UnicodeString AFileName, boo
// but still want to have filename-only in FileName
AFileName = UnixExtractFileName(AFileName);
}
FileName = AFileName;
FileInProgress = AFileInProgress;
FFileName = AFileName;
FFileInProgress = AFileInProgress;
ClearTransfer();
FFileStartTime = Now();
DoProgress();
@@ -239,22 +241,22 @@ void __fastcall TFileOperationProgressType::SetFile(UnicodeString AFileName, boo
void __fastcall TFileOperationProgressType::SetFileInProgress()
{
DebugAssert(!FileInProgress);
FileInProgress = true;
FFileInProgress = true;
DoProgress();
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetLocalSize(__int64 ASize)
{
LocalSize = ASize;
FLocalSize = ASize;
DoProgress();
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::AddLocallyUsed(__int64 ASize)
{
LocallyUsed += ASize;
FLocallyUsed += ASize;
if (LocallyUsed > LocalSize)
{
LocalSize = LocallyUsed;
FLocalSize = LocallyUsed;
}
DoProgress();
}
@@ -338,48 +340,91 @@ unsigned long __fastcall TFileOperationProgressType::LocalBlockSize()
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetTotalSize(__int64 ASize)
{
TotalSize = ASize;
TotalSizeSet = true;
FTotalSize = ASize;
FTotalSizeSet = true;
DoProgress();
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetTransferSize(__int64 ASize)
{
TransferSize = ASize;
FTransferSize = ASize;
DoProgress();
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetTransferingFile(bool ATransferingFile)
{
FTransferingFile = ATransferingFile;
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetCancel(TCancelStatus ACancel)
{
FCancel = ACancel;
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetCancelAtLeast(TCancelStatus ACancel)
{
if (FCancel < ACancel)
{
FCancel = ACancel;
}
}
//---------------------------------------------------------------------------
bool __fastcall TFileOperationProgressType::ClearCancelFile()
{
bool Result = (Cancel == csCancelFile);
if (Result)
{
SetCancel(csContinue);
}
return Result;
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetCPSLimit(unsigned long ACPSLimit)
{
FCPSLimit = ACPSLimit;
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetBatchOverwrite(TBatchOverwrite ABatchOverwrite)
{
FBatchOverwrite = ABatchOverwrite;
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetSkipToAll()
{
FSkipToAll = true;
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::ChangeTransferSize(__int64 ASize)
{
// reflect change on file size (due to text transfer mode conversion particulary)
// on total transfer size
if (TotalSizeSet)
{
TotalSize += (ASize - TransferSize);
FTotalSize += (ASize - TransferSize);
}
TransferSize = ASize;
FTransferSize = ASize;
DoProgress();
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::RollbackTransfer()
{
TransferedSize -= SkippedSize;
FTransferedSize -= SkippedSize;
DebugAssert(TransferedSize <= TotalTransfered);
TotalTransfered -= TransferedSize;
FTotalTransfered -= TransferedSize;
DebugAssert(SkippedSize <= TotalSkipped);
FTicks.clear();
FTotalTransferredThen.clear();
TotalSkipped -= SkippedSize;
SkippedSize = 0;
TransferedSize = 0;
TransferSize = 0;
LocallyUsed = 0;
FTotalSkipped -= SkippedSize;
FSkippedSize = 0;
FTransferedSize = 0;
FTransferSize = 0;
FLocallyUsed = 0;
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::AddTransfered(__int64 ASize,
bool AddToTotals)
{
TransferedSize += ASize;
FTransferedSize += ASize;
if (TransferedSize > TransferSize)
{
// this can happen with SFTP when downloading file that
@@ -387,13 +432,13 @@ void __fastcall TFileOperationProgressType::AddTransfered(__int64 ASize,
if (TotalSizeSet)
{
// we should probably guard this with AddToTotals
TotalSize += (TransferedSize - TransferSize);
FTotalSize += (TransferedSize - TransferSize);
}
TransferSize = TransferedSize;
FTransferSize = TransferedSize;
}
if (AddToTotals)
{
TotalTransfered += ASize;
FTotalTransfered += ASize;
unsigned long Ticks = GetTickCount();
if (FTicks.empty() ||
(FTicks.back() > Ticks) || // ticks wrap after 49.7 days
@@ -414,15 +459,15 @@ void __fastcall TFileOperationProgressType::AddTransfered(__int64 ASize,
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::AddResumed(__int64 ASize)
{
TotalSkipped += ASize;
SkippedSize += ASize;
FTotalSkipped += ASize;
FSkippedSize += ASize;
AddTransfered(ASize, false);
AddLocallyUsed(ASize);
}
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::AddSkippedFileSize(__int64 ASize)
{
TotalSkipped += ASize;
FTotalSkipped += ASize;
DoProgress();
}
//---------------------------------------------------------------------------
@@ -450,7 +495,7 @@ bool __fastcall TFileOperationProgressType::IsTransferDone()
//---------------------------------------------------------------------------
void __fastcall TFileOperationProgressType::SetAsciiTransfer(bool AAsciiTransfer)
{
AsciiTransfer = AAsciiTransfer;
FAsciiTransfer = AAsciiTransfer;
DoProgress();
}
//---------------------------------------------------------------------------

View File

@@ -23,6 +23,33 @@ typedef void __fastcall (__closure *TFileOperationFinished)
class TFileOperationProgressType
{
private:
TFileOperation FOperation;
TOperationSide FSide;
UnicodeString FFileName;
UnicodeString FFullFileName;
UnicodeString FDirectory;
bool FAsciiTransfer;
bool FTransferingFile;
bool FTemp;
__int64 FLocalSize;
__int64 FLocallyUsed;
__int64 FTransferSize;
__int64 FTransferedSize;
__int64 FSkippedSize;
bool FInProgress;
bool FFileInProgress;
TCancelStatus FCancel;
int FCount;
TDateTime FStartTime;
__int64 FTotalTransfered;
__int64 FTotalSkipped;
__int64 FTotalSize;
TBatchOverwrite FBatchOverwrite;
bool FSkipToAll;
unsigned long FCPSLimit;
bool FTotalSizeSet;
bool FSuspended;
// when it was last time suspended (to calculate suspend time in Resume())
unsigned int FSuspendTime;
// when current file was started being transfered
@@ -40,44 +67,45 @@ private:
protected:
void __fastcall ClearTransfer();
inline void __fastcall DoProgress();
int __fastcall OperationProgress();
public:
// common data
TFileOperation Operation;
__property TFileOperation Operation = { read = FOperation };
// on what side if operation being processed (local/remote), source of copy
TOperationSide Side;
UnicodeString FileName;
UnicodeString FullFileName;
UnicodeString Directory;
bool AsciiTransfer;
__property TOperationSide Side = { read = FSide };
__property UnicodeString FileName = { read = FFileName };
__property UnicodeString FullFileName = { read = FFullFileName };
__property UnicodeString Directory = { read = FDirectory };
__property bool AsciiTransfer = { read = FAsciiTransfer };
// Can be true with SCP protocol only
bool TransferingFile;
bool Temp;
__property bool TransferingFile = { read = FTransferingFile };
__property bool Temp = { read = FTemp };
// file size to read/write
__int64 LocalSize;
__int64 LocallyUsed;
__int64 TransferSize;
__int64 TransferedSize;
__int64 SkippedSize;
bool InProgress;
bool FileInProgress;
TCancelStatus Cancel;
int Count;
__property __int64 LocalSize = { read = FLocalSize };
__property __int64 LocallyUsed = { read = FLocallyUsed };
__property __int64 TransferSize = { read = FTransferSize };
__property __int64 TransferedSize = { read = FTransferedSize };
__property __int64 SkippedSize = { read = FSkippedSize };
__property bool InProgress = { read = FInProgress };
__property bool FileInProgress = { read = FFileInProgress };
__property TCancelStatus Cancel = { read = FCancel };
__property int Count = { read = FCount };
// when operation started
TDateTime StartTime;
__property TDateTime StartTime = { read = FStartTime };
// bytes transfered
__int64 TotalTransfered;
__int64 TotalSkipped;
__int64 TotalSize;
__property __int64 TotalTransfered = { read = FTotalTransfered };
__property __int64 TotalSkipped = { read = FTotalSkipped };
__property __int64 TotalSize = { read = FTotalSize };
TBatchOverwrite BatchOverwrite;
bool SkipToAll;
unsigned long CPSLimit;
__property TBatchOverwrite BatchOverwrite = { read = FBatchOverwrite };
__property bool SkipToAll = { read = FSkipToAll };
__property unsigned long CPSLimit = { read = FCPSLimit };
bool TotalSizeSet;
__property bool TotalSizeSet = { read = FTotalSizeSet };
bool Suspended;
__property bool Suspended = { read = FSuspended };
__fastcall TFileOperationProgressType();
__fastcall TFileOperationProgressType(
@@ -98,7 +126,6 @@ public:
bool __fastcall IsTransferDone();
void __fastcall SetFile(UnicodeString AFileName, bool AFileInProgress = true);
void __fastcall SetFileInProgress();
int __fastcall OperationProgress();
unsigned long __fastcall TransferBlockSize();
unsigned long __fastcall AdjustToCPSLimit(unsigned long Size);
void __fastcall ThrottleToCPSLimit(unsigned long Size);
@@ -127,6 +154,13 @@ public:
int __fastcall OverallProgress();
int __fastcall TotalTransferProgress();
void __fastcall SetSpeedCounters();
void __fastcall SetTransferingFile(bool ATransferingFile);
void __fastcall SetCancel(TCancelStatus ACancel);
void __fastcall SetCancelAtLeast(TCancelStatus ACancel);
bool __fastcall ClearCancelFile();
void __fastcall SetCPSLimit(unsigned long ACPSLimit);
void __fastcall SetBatchOverwrite(TBatchOverwrite ABatchOverwrite);
void __fastcall SetSkipToAll();
};
//---------------------------------------------------------------------------
class TSuspendFileOperationProgress

View File

@@ -1368,10 +1368,7 @@ bool __fastcall TFTPFileSystem::ConfirmOverwrite(
}
else
{
if (!OperationProgress->Cancel)
{
OperationProgress->Cancel = csCancel;
}
OperationProgress->SetCancelAtLeast(csCancel);
FFileTransferAbort = ftaCancel;
Result = false;
}
@@ -1382,10 +1379,7 @@ bool __fastcall TFTPFileSystem::ConfirmOverwrite(
break;
case qaCancel:
if (!OperationProgress->Cancel)
{
OperationProgress->Cancel = csCancel;
}
OperationProgress->SetCancelAtLeast(csCancel);
FFileTransferAbort = ftaCancel;
Result = false;
break;
@@ -1455,9 +1449,8 @@ void __fastcall TFTPFileSystem::DoFileTransferProgress(__int64 TransferSize,
if (OperationProgress->Cancel != csContinue)
{
if (OperationProgress->Cancel == csCancelFile)
if (OperationProgress->ClearCancelFile())
{
OperationProgress->Cancel = csContinue;
FFileTransferAbort = ftaSkip;
}
else
@@ -1716,8 +1709,6 @@ void __fastcall TFTPFileSystem::Sink(const UnicodeString FileName,
}
FILE_OPERATION_LOOP_END(FMTLOAD(NOT_FILE_ERROR, (DestFullName)));
OperationProgress->TransferingFile = false; // not set with FTP protocol
ResetFileTransfer();
TFileTransferData UserData;
@@ -1958,7 +1949,6 @@ void __fastcall TFTPFileSystem::Source(const UnicodeString FileName,
// Suppose same data size to transfer as to read
// (not true with ASCII transfer)
OperationProgress->SetTransferSize(OperationProgress->LocalSize);
OperationProgress->TransferingFile = false;
TDateTime Modification;
// Inspired by SysUtils::FileAge

View File

@@ -1515,11 +1515,11 @@ void __fastcall TTerminalItem::OperationProgress(
{
if (ProgressData.TransferingFile)
{
ProgressData.Cancel = csCancelTransfer;
ProgressData.SetCancel(csCancelTransfer);
}
else
{
ProgressData.Cancel = csCancel;
ProgressData.SetCancel(csCancel);
}
}
@@ -1613,7 +1613,7 @@ void __fastcall TQueueItem::SetProgress(
// wait until the real transfer operation starts
if ((FCPSLimit >= 0) && ((ProgressData.Operation == foMove) || (ProgressData.Operation == foCopy)))
{
ProgressData.CPSLimit = static_cast<unsigned long>(FCPSLimit);
ProgressData.SetCPSLimit(static_cast<unsigned long>(FCPSLimit));
FCPSLimit = -1;
}

View File

@@ -1586,7 +1586,7 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy,
break;
case qaCancel:
if (!OperationProgress->Cancel) OperationProgress->Cancel = csCancel;
OperationProgress->SetCancelAtLeast(csCancel);
case qaNo:
CanProceed = false;
break;
@@ -1634,7 +1634,7 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy,
if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (FileName)), &E,
qaOK | qaAbort, &Params, qtError) == qaAbort)
{
OperationProgress->Cancel = csCancel;
OperationProgress->SetCancel(csCancel);
}
OperationProgress->Finish(FileName, false, OnceDoneOperation);
if (!FTerminal->HandleException(&E))
@@ -1746,7 +1746,7 @@ void __fastcall TSCPFileSystem::SCPSource(const UnicodeString FileName,
// Suppose same data size to transfer as to read
// (not true with ASCII transfer)
OperationProgress->SetTransferSize(OperationProgress->LocalSize);
OperationProgress->TransferingFile = false;
OperationProgress->SetTransferingFile(false);
TDateTime Modification = UnixToDateTime(MTime, FTerminal->SessionData->DSTMode);
@@ -1854,7 +1854,7 @@ void __fastcall TSCPFileSystem::SCPSource(const UnicodeString FileName,
SCPResponse();
// Indicate we started transferring file, we need to finish it
// If not, it's fatal error
OperationProgress->TransferingFile = true;
OperationProgress->SetTransferingFile(true);
// If we're doing ASCII transfer, this is last pass
// so we send whole file
@@ -1916,19 +1916,19 @@ void __fastcall TSCPFileSystem::SCPSource(const UnicodeString FileName,
catch (EScp &E)
{
// SCP protocol fatal error
OperationProgress->TransferingFile = false;
OperationProgress->SetTransferingFile(false);
throw;
}
catch (EScpFileSkipped &E)
{
// SCP protocol non-fatal error
OperationProgress->TransferingFile = false;
OperationProgress->SetTransferingFile(false);
throw;
}
// We succeeded transferring file, from now we can handle exceptions
// normally -> no fatal error
OperationProgress->TransferingFile = false;
OperationProgress->SetTransferingFile(false);
}
catch (Exception &E)
{
@@ -2074,7 +2074,7 @@ void __fastcall TSCPFileSystem::SCPDirectorySource(const UnicodeString Directory
if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (FileName)), &E,
qaOK | qaAbort, &Params, qtError) == qaAbort)
{
OperationProgress->Cancel = csCancel;
OperationProgress->SetCancel(csCancel);
}
if (!FTerminal->HandleException(&E))
{
@@ -2173,7 +2173,7 @@ void __fastcall TSCPFileSystem::CopyToLocal(TStrings * FilesToCopy,
// remote side closed SCP, but we continue with next file
if (OperationProgress->Cancel == csRemoteAbort)
{
OperationProgress->Cancel = csContinue;
OperationProgress->SetCancel(csContinue);
}
// Move operation -> delete file/directory afterwards
@@ -2212,7 +2212,7 @@ void __fastcall TSCPFileSystem::CopyToLocal(TStrings * FilesToCopy,
// is closed already
if (OperationProgress->Cancel == csCancel)
{
OperationProgress->Cancel = csRemoteAbort;
OperationProgress->SetCancel(csRemoteAbort);
}
Success = false;
}
@@ -2322,7 +2322,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir,
{
// Remote side finished copying, so remote SCP was closed
// and we don't need to terminate it manually, see CopyToLocal()
OperationProgress->Cancel = csRemoteAbort;
OperationProgress->SetCancel(csRemoteAbort);
/* TODO 1 : Show stderror to user? */
FSecureShell->ClearStdError();
try
@@ -2522,7 +2522,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir,
switch (Answer)
{
case qaCancel:
OperationProgress->Cancel = csCancel; // continue on next case
OperationProgress->SetCancel(csCancel); // continue on next case
case qaNo:
SkipConfirmed = true;
EXCEPTION;
@@ -2550,7 +2550,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir,
// We succeeded, so we confirm transfer to remote side
FSecureShell->SendNull();
// From now we need to finish file transfer, if not it's fatal error
OperationProgress->TransferingFile = true;
OperationProgress->SetTransferingFile(true);
// Suppose same data size to transfer as to write
// (not true with ASCII transfer)
@@ -2610,7 +2610,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir,
FMTLOAD(COPY_FATAL, (OperationProgress->FileName)));
}
OperationProgress->TransferingFile = false;
OperationProgress->SetTransferingFile(false);
try
{
@@ -2679,7 +2679,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir,
if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (AbsoluteFileName)),
&E, qaOK | qaAbort, &Params, qtError) == qaAbort)
{
OperationProgress->Cancel = csCancel;
OperationProgress->SetCancel(csCancel);
}
FTerminal->Log->AddException(&E);
}

View File

@@ -2298,7 +2298,7 @@ void __fastcall TManagementScript::TerminalOperationProgress(
if (QueryCancel())
{
ProgressData.Cancel = csCancel;
ProgressData.SetCancel(csCancel);
}
}
//---------------------------------------------------------------------------

View File

@@ -4399,15 +4399,12 @@ void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(
case qaNoToAll:
OverwriteMode = omResume;
OperationProgress->BatchOverwrite = boAlternateResume;
OperationProgress->SetBatchOverwrite(boAlternateResume);
break;
default: DebugFail(); //fallthru
case qaCancel:
if (!OperationProgress->Cancel)
{
OperationProgress->Cancel = csCancel;
}
OperationProgress->SetCancelAtLeast(csCancel);
Abort();
break;
}
@@ -4422,10 +4419,7 @@ void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(
}
else
{
if (!OperationProgress->Cancel)
{
OperationProgress->Cancel = csCancel;
}
OperationProgress->SetCancelAtLeast(csCancel);
Abort();
}
}
@@ -4435,10 +4429,7 @@ void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(
switch (Answer)
{
case qaCancel:
if (!OperationProgress->Cancel)
{
OperationProgress->Cancel = csCancel;
}
OperationProgress->SetCancelAtLeast(csCancel);
Abort();
break;
@@ -4466,10 +4457,7 @@ bool TSFTPFileSystem::SFTPConfirmResume(const UnicodeString DestFileName,
if (Answer == qaAbort)
{
if (!OperationProgress->Cancel)
{
OperationProgress->Cancel = csCancel;
}
OperationProgress->SetCancelAtLeast(csCancel);
Abort();
}
ResumeTransfer = false;
@@ -4500,10 +4488,7 @@ bool TSFTPFileSystem::SFTPConfirmResume(const UnicodeString DestFileName,
break;
case qaCancel:
if (!OperationProgress->Cancel)
{
OperationProgress->Cancel = csCancel;
}
OperationProgress->SetCancelAtLeast(csCancel);
Abort();
break;
}
@@ -4619,7 +4604,6 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName,
// Suppose same data size to transfer as to read
// (not true with ASCII transfer)
OperationProgress->SetTransferSize(OperationProgress->LocalSize);
OperationProgress->TransferingFile = false;
TDateTime Modification = UnixToDateTime(MTime, FTerminal->SessionData->DSTMode);
@@ -4846,9 +4830,8 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName,
{
if (OperationProgress->Cancel)
{
if (OperationProgress->Cancel == csCancelFile)
if (OperationProgress->ClearCancelFile())
{
OperationProgress->Cancel = csContinue;
THROW_SKIP_FILE_NULL;
}
else
@@ -5677,8 +5660,6 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName,
}
FILE_OPERATION_LOOP_END(FMTLOAD(NOT_FILE_ERROR, (DestFullName)));
OperationProgress->TransferingFile = false; // not set with SFTP protocol
HANDLE LocalHandle = NULL;
TStream * FileStream = NULL;
bool DeleteLocalFile = false;
@@ -6008,9 +5989,8 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName,
if (OperationProgress->Cancel != csContinue)
{
if (OperationProgress->Cancel == csCancelFile)
if (OperationProgress->ClearCancelFile())
{
OperationProgress->Cancel = csContinue;
THROW_SKIP_FILE_NULL;
}
else

View File

@@ -1781,7 +1781,7 @@ bool __fastcall TTerminal::FileOperationLoopQuery(Exception & E,
if (Answer == qaAll)
{
DebugAssert(OperationProgress != NULL);
OperationProgress->SkipToAll = true;
OperationProgress->SetSkipToAll();
Answer = qaSkip;
}
if (Answer == qaYes)
@@ -1795,7 +1795,7 @@ bool __fastcall TTerminal::FileOperationLoopQuery(Exception & E,
{
if ((Answer == qaAbort) && (OperationProgress != NULL))
{
OperationProgress->Cancel = csCancel;
OperationProgress->SetCancel(csCancel);
}
if (AllowSkip)
@@ -2263,7 +2263,7 @@ unsigned int __fastcall TTerminal::CommandError(Exception * E, const UnicodeStri
if (Result == qaAll)
{
DebugAssert(OperationProgress != NULL);
OperationProgress->SkipToAll = true;
OperationProgress->SetSkipToAll();
Result = qaSkip;
}
}
@@ -2421,7 +2421,7 @@ unsigned int __fastcall TTerminal::ConfirmFileOverwrite(
// to current transfer (see condition above)
if (BatchOverwrite != boNo)
{
OperationProgress->BatchOverwrite = BatchOverwrite;
OperationProgress->SetBatchOverwrite(BatchOverwrite);
}
}
@@ -4305,9 +4305,9 @@ bool __fastcall TTerminal::DoCreateLocalFile(const UnicodeString FileName,
}
switch (Answer) {
case qaYesToAll: OperationProgress->BatchOverwrite = boAll; break;
case qaCancel: OperationProgress->Cancel = csCancel; // continue on next case
case qaNoToAll: OperationProgress->BatchOverwrite = boNone;
case qaYesToAll: OperationProgress->SetBatchOverwrite(boAll); break;
case qaCancel: OperationProgress->SetCancel(csCancel); // continue on next case
case qaNoToAll: OperationProgress->SetBatchOverwrite(boNone);
case qaNo: Result = false; break;
}
}

View File

@@ -1245,10 +1245,7 @@ void __fastcall TWebDAVFileSystem::ConfirmOverwrite(
default:
DebugFail();
case qaCancel:
if (!OperationProgress->Cancel)
{
OperationProgress->Cancel = csCancel;
}
OperationProgress->SetCancelAtLeast(csCancel);
Abort();
break;
}
@@ -1475,7 +1472,6 @@ void __fastcall TWebDAVFileSystem::Source(const UnicodeString FileName,
// Suppose same data size to transfer as to read
// (not true with ASCII transfer)
OperationProgress->SetTransferSize(OperationProgress->LocalSize);
OperationProgress->TransferingFile = false;
UnicodeString DestFullName = TargetDir + DestFileName;
@@ -2022,9 +2018,8 @@ bool __fastcall TWebDAVFileSystem::CancelTransfer()
(FTerminal->OperationProgress != NULL) &&
(FTerminal->OperationProgress->Cancel != csContinue))
{
if (FTerminal->OperationProgress->Cancel == csCancelFile)
if (FTerminal->OperationProgress->ClearCancelFile())
{
FTerminal->OperationProgress->Cancel = csContinue;
FSkipped = true;
}
else
@@ -2178,8 +2173,6 @@ void __fastcall TWebDAVFileSystem::Sink(const UnicodeString FileName,
}
FILE_OPERATION_LOOP_END(FMTLOAD(NOT_FILE_ERROR, (DestFullName)));
OperationProgress->TransferingFile = false; // not set with WebDAV protocol
UnicodeString FilePath = ::UnixExtractFilePath(FileName);
if (FilePath.IsEmpty())
{

View File

@@ -843,9 +843,13 @@ void __fastcall TCustomScpExplorerForm::SetQueueProgress()
{
if (FQueueStatus->ActiveCount == 1)
{
TFileOperationProgressType * ProgressData;
if ((FQueueStatus->Items[FQueueStatus->DoneCount] != NULL) &&
((ProgressData = FQueueStatus->Items[FQueueStatus->DoneCount]->ProgressData) != NULL) &&
TFileOperationProgressType * ProgressData = NULL;
if (FQueueStatus->Items[FQueueStatus->DoneCount] != NULL)
{
ProgressData = FQueueStatus->Items[FQueueStatus->DoneCount]->ProgressData;
}
if ((ProgressData != NULL) &&
ProgressData->InProgress)
{
SetTaskbarListProgressValue(ProgressData);
@@ -1352,24 +1356,15 @@ void __fastcall TCustomScpExplorerForm::FileOperationProgress(
if (FProgressForm->Cancel > csContinue)
{
if (FProgressForm->Cancel > ProgressData.Cancel)
{
ProgressData.Cancel = FProgressForm->Cancel;
}
if (FProgressForm->Cancel == csCancelFile)
{
FProgressForm->Cancel = csContinue;
}
ProgressData.SetCancelAtLeast(FProgressForm->Cancel);
ProgressData.ClearCancelFile();
// cancel cancels even the move
FMoveToQueue = false;
}
else if (FProgressForm->MoveToQueue)
{
FMoveToQueue = true;
if (ProgressData.Cancel < csCancel)
{
ProgressData.Cancel = csCancel;
}
ProgressData.SetCancelAtLeast(csCancel);
}
if ((FTransferResumeList != NULL) &&

View File

@@ -395,7 +395,7 @@ void __fastcall TProgressForm::SetProgressData(TFileOperationProgressType & ADat
}
FUpdateCounter++;
AData.CPSLimit = FCPSLimit;
AData.SetCPSLimit(FCPSLimit);
}
//---------------------------------------------------------------------------
void __fastcall TProgressForm::UpdateTimerTimer(TObject * /*Sender*/)