Skip to content

Commit 1bbf7ff

Browse files
authored
Fix an issue where comparison results are not displayed correctly when "Refresh Selected" is performed by selecting an item that has a directory and file with the same name. (#1189)
- Change to judge that a directory or file exists only if the rescanned item type (directory or file) matches the original diffItem type in the diffItem update process.
1 parent d9368ac commit 1bbf7ff

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Src/DirItem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,12 @@ void DirItem::ClearPartial()
9898
size = DirItem::FILE_SIZE_NONE;
9999
flags.reset();
100100
}
101+
102+
/**
103+
* @brief Return whether the item is a directory.
104+
* @return true if the item is a directory.
105+
*/
106+
bool DirItem::IsDirectory() const
107+
{
108+
return ((flags.attributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
109+
}

Src/DirItem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ struct DirItem
3737
String GetFile() const;
3838
bool Update(const String &sFilePath);
3939
void ClearPartial();
40+
bool IsDirectory() const;
4041
};

Src/DirScan.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,15 @@ static void UpdateDiffItem(DIFFITEM &di, bool & bExists, CDiffContext *pCtxt)
783783
di.diffFileInfo[i].ClearPartial();
784784
if (pCtxt->UpdateInfoFromDiskHalf(di, i))
785785
{
786-
di.diffcode.diffcode |= DIFFCODE::FIRST << i;
787-
bExists = true;
786+
if (di.diffFileInfo[i].IsDirectory() == di.diffcode.isDirectory())
787+
{
788+
di.diffcode.diffcode |= DIFFCODE::FIRST << i;
789+
bExists = true;
790+
}
791+
else
792+
{
793+
di.diffFileInfo[i].ClearPartial();
794+
}
788795
}
789796
}
790797
}

0 commit comments

Comments
 (0)