<table><tr><td style="">aacid created this revision.<br />Herald added a project: Frameworks.<br />Herald added a subscriber: kde-frameworks-devel.<br />aacid requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D20519">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>findOrCreate has some code that tries to recover broken files.</p>
<p>That code will delete an empty file if later it looks like it should be a directory.</p>
<p>The problem is that that code, was doing</p>
<p>entry = rootDir->get(path)<br />
if (entry is not dir and it's 0 size) {<br />
rootDir->remove(entry)<br />
delete entry;<br />
}</p>
<p>But unfortunately get() and remove() are not equally stubborn.</p>
<p>get will try to see if the path lives in a subdir while remove only will remove entries in the exact dir.</p>
<p>So it might happen that the old code did call remove() on the root dir but that did nothing since the entry didn't belong to the root dir.</p>
<p>This failure would result in a double delete when the dir that actually contains the entry would be deleted.</p>
<p>This patch introduces a private get that will also return which directory entry exactly lives on so remove succeeds and no double delete happens.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R243 KArchive</div></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D20519">https://phabricator.kde.org/D20519</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/karchive.cpp<br />
src/karchivedirectory.h</div></div></div><br /><div><strong>To: </strong>aacid<br /><strong>Cc: </strong>kde-frameworks-devel, michaelh, ngraham, bruns<br /></div>