Skip to content

Commit

Permalink
Bug 41 implementation was not working with panel sorting + Failure wh…
Browse files Browse the repository at this point in the history
…en calculating directory sizes in local-local mode

https://winscp.net/tracker/41

Source commit: d63b35133175c7c97532883dc64b901228b90798
  • Loading branch information
martinprikryl committed Dec 14, 2022
1 parent 48106ee commit 09646b5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
9 changes: 7 additions & 2 deletions source/components/UnixDirView.cpp
Expand Up @@ -231,11 +231,16 @@ UnicodeString __fastcall TUnixDirView::ItemFileName(TListItem * Item)
#endif
}
//---------------------------------------------------------------------------
inline __int64 GetItemFileSize(TRemoteFile * File)
{
return (File->CalculatedSize >= 0) ? File->CalculatedSize : File->Size;
}
//---------------------------------------------------------------------------
__int64 __fastcall TUnixDirView::ItemFileSize(TListItem * Item)
{
#ifndef DESIGN_ONLY
ASSERT_VALID_ITEM;
return (ITEMFILE->CalculatedSize >= 0) ? ITEMFILE->CalculatedSize : ITEMFILE->Size;
return GetItemFileSize(ITEMFILE);
#else
DebugUsedParam(Item);
return 0;
Expand Down Expand Up @@ -779,7 +784,7 @@ int __stdcall CompareFile(TListItem * Item1, TListItem * Item2, TUnixDirView * D
break;

case uvSize:
Result = COMPARE_NUMBER(File1->Size, File2->Size);
Result = COMPARE_NUMBER(GetItemFileSize(File1), GetItemFileSize(File2));
break;

case uvChanged:
Expand Down
2 changes: 1 addition & 1 deletion source/forms/CustomScpExplorer.cpp
Expand Up @@ -11701,7 +11701,7 @@ void TCustomScpExplorerForm::CalculateDirectorySizes()

if (Side == osLocal)
{
Terminal->CalculateLocalFilesSize(FileList.get(), Size, NULL, true, NULL, &CalculatedSizes);
ManagedSession->CalculateLocalFilesSize(FileList.get(), Size, NULL, true, NULL, &CalculatedSizes);
}
else
{
Expand Down
17 changes: 11 additions & 6 deletions source/packages/filemng/DirView.pas
Expand Up @@ -2050,6 +2050,14 @@ function CompareFileTime(P1, P2: PFileRec): Integer;
else Result := fEqual; // fallback
end;

function GetItemFileSize(P: PFileRec): Int64; inline;
begin
Result := 0;
if P.Size >= 0 then Result := P.Size
else
if P.CalculatedSize >= 0 then Result := P.CalculatedSize;
end;

function CompareFile(I1, I2: TListItem; AOwner: TDirView): Integer; stdcall;
var
ConsiderDirection: Boolean;
Expand Down Expand Up @@ -2106,9 +2114,9 @@ function CompareFile(I1, I2: TListItem; AOwner: TDirView): Integer; stdcall;
; // fallback

dvSize:
if P1.Size < P2.Size then Result := fLess
if GetItemFileSize(P1) < GetItemFileSize(P2) then Result := fLess
else
if P1.Size > P2.Size then Result := fGreater
if GetItemFileSize(P1) > GetItemFileSize(P2) then Result := fGreater
else ; // fallback

dvType:
Expand Down Expand Up @@ -2972,10 +2980,7 @@ function TDirView.ItemFileSize(Item: TListItem): Int64;
begin
Result := 0;
if Assigned(Item) and Assigned(Item.Data) then
with PFileRec(Item.Data)^ do
if Size >= 0 then Result := Size
else
if CalculatedSize >= 0 then Result := CalculatedSize;
Result := GetItemFileSize(PFileRec(Item.Data));
end;

function TDirView.ItemFileTime(Item: TListItem;
Expand Down

0 comments on commit 09646b5

Please sign in to comment.