Skip to content

Commit

Permalink
Fix issue #2046: Folder compare omits unique folders from results if …
Browse files Browse the repository at this point in the history
…they contain any files and/or subfolders

Revert commit "Fix issue #1588: File Duplication Bug In Outputted Zips" and redo the fix.
  • Loading branch information
sdottaka committed Sep 29, 2023
1 parent 69ba23c commit d6f48c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
19 changes: 8 additions & 11 deletions Src/7zCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,14 @@ const DIFFITEM &DirItemEnumerator::Next()
m_index++;
}
const auto& di = m_pView->GetDiffItem(m_nIndex);
// If the current item is a folder, ignore the current item if the next selected item is a child element of that folder.
if (m_index > (((di.diffcode.diffcode & DIFFCODE::THREEWAY) == 0) ? 1 : 2) || !di.diffcode.isDirectory())
return di;
const int nextIndex = pView(m_pView)->GetNextItem(m_nIndex, m_nFlags & nMask);
if (nextIndex == -1)
return di;
const auto& diNext = m_pView->GetDiffItem(nextIndex);
const String curRelPath = strutils::makelower(di.diffFileInfo[m_index].GetFile());
if (strutils::makelower(diNext.diffFileInfo[m_index].GetFile()).find(curRelPath) != 0)
return di;
return *DIFFITEM::GetEmptyItem();
for (const auto* pfdi : m_selectedFolderDiffItems)
{
if (di.IsAncestor(pfdi))
return *DIFFITEM::GetEmptyItem();
}
if (di.diffcode.isDirectory())
m_selectedFolderDiffItems.push_back(&di);
return di;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Src/7zCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Merge7z::Proxy embeds a DLLPSTUB
#include <list>
#include <map>
#include <vector>
#include <PropIdl.h>
#include "dllpstub.h"
#include "../ArchiveSupport/Merge7z/Merge7z.h"
Expand Down Expand Up @@ -67,6 +68,7 @@ class DirItemEnumerator : public Merge7z::DirItemEnumerator
};
std::list<String> m_rgFolderPrefix;
std::list<String>::iterator m_curFolderPrefix;
std::vector<const DIFFITEM*> m_selectedFolderDiffItems;
String m_strFolderPrefix;
int m_index;
std::map<String, void *> m_rgImpliedFolders[3];
Expand Down
2 changes: 1 addition & 1 deletion Src/DirView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ void CDirView::RedisplayChildren(DIFFITEM *diffpos, int level, UINT &index, int
}
else
{
if (!ctxt.m_bRecursive || !di.diffcode.isDirectory() || (!di.diffcode.existAll() && !di.HasChildren()))
if (!ctxt.m_bRecursive || !di.diffcode.isDirectory() || !di.diffcode.existAll())
{
AddNewItem(index, curdiffpos, I_IMAGECALLBACK, 0);
index++;
Expand Down

0 comments on commit d6f48c4

Please sign in to comment.