<table><tr><td style="">dmitrio created this revision.<br />dmitrio added a project: Frameworks.<br />dmitrio 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/D10663" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>BUG: 383764</p>

<p>Remove a partially copied file if copyjob was cancelled in the middle of file copying.</p>

<p>File is considered to be in the process of being copied after some data block is actually written (or, to be more precise, slotProcessedSize is called). This should help us avoid cleaning up by mistake files that existed before the operation. This also means that in some very rare occasions when user cancels copying in the very beginning of the operation cleaning up procedure may not work — which is, I believe, the best result we can obtain without more significant code changes.</p>

<p>Unlike <a href="https://phabricator.kde.org/D10635" class="remarkup-link" target="_blank" rel="noreferrer">this proposal</a>, my option does not include handling of the full disk or any other errors. In its current state it applies only to the case when job gets killed by user.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>While I am not sure about automated testing, various manual testing scenarios can be suggested:</p>

<p>I.</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Start copying a large file(s) to  empty directory</li>
<li class="remarkup-list-item">Cancel copying</li>
<li class="remarkup-list-item">File which copying was cancelled should <strong>not</strong> be present at the destination.</li>
</ol>

<p>II.</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Start copying a large file(s) to the directory with existing files with colliding names</li>
<li class="remarkup-list-item">Cancel copying (not via "File exists" dialog)</li>
<li class="remarkup-list-item">Original file should be present at the destination</li>
</ol>

<p>One may also want to test behavior in situation when it is not possible to delete the file.<br />
For example:</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Start copying a file to some network folder</li>
<li class="remarkup-list-item">Turn off network connection</li>
<li class="remarkup-list-item">Cancel copying</li>
<li class="remarkup-list-item">File deletion UI should appear in the notifications area. You should now be able to cancel deletion or wait a bit for an error message.</li>
</ol></div></div><br /><div><strong>REPOSITORY</strong><div><div>R241 KIO</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D10663" rel="noreferrer">https://phabricator.kde.org/D10663</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/core/copyjob.cpp<br />
src/core/copyjob.h</div></div></div><br /><div><strong>To: </strong>dmitrio<br /><strong>Cc: </strong>Frameworks, michaelh<br /></div>