<table><tr><td style="">dfaure requested changes to this revision.<br />dfaure added a comment.<br />This revision now requires changes to proceed.
</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/D10635" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>The idea kind of makes sense, but as is, it's very dangerous, what if the destination already existed?</p>

<p>Case 1: copy file:///dir1 to ftp://host/dir2 which already exists. During the 'stat src' or 'stat dest' phase, cancel the job -> it will now delete dir2 !<br />
(see copyjob.cpp:879 which sets m_currentDestURL).</p>

<p>Case 2: *move* dir1 to dir2 which already exists, cancel before the move happens, boom.</p>

<p>I don't have time to think about more cases, but I suspect there are some more.</p>

<p>Unittesting "cancelling at this exact step of the copy" sounds very tricky, unfortunately... but maybe we can add unittest-specific env vars to abort with a disk full error at some points in the code.</p>

<p>Also, why is this done at the PasteJob level? there are many other ways to trigger a copy, including drag-n-drop. It sounds like this should rather be done inside CopyJob, which would also make it possible to have more information about whether it's safe to clean up or not.</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10635#inline-50557" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.h:99</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #74777d">     * Returns the current file destination URL.</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #74777d">     * @return the current file destination URL</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #74777d">     */</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;"><span class="phabricator-remarkup-mention-unknown">@since</span> 5.44 if it has to be public, but please also document what this really is, for people who haven't read the copyjob.cpp source code.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10635#inline-50558" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">dropjob.cpp:559</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "><span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">    <span style="color: #aa4000">i<span class="bright">f</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="n">job</span><span style="color: #aa2211">-></span><span class="n">error</span><span class="p">()<span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #aa4000">i<span class="bright">nt</span></span><span class="bright"> </span><span class="n"><span class="bright">jobError</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span class="n">job</span><span style="color: #aa2211">-></span><span class="n">error</span><span class="p">()<span class="bright">;</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">jobError</span><span class="p">)</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">const int...</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10635#inline-50559" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">dropjob.cpp:563</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #74777d">// Must remove last file that was not finished moving/copying</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="n">KIO</span><span style="color: #aa2211">::</span><span class="n">CopyJob</span> <span style="color: #aa2211">*</span><span class="n">copyJob</span> <span style="color: #aa2211">=</span> <span class="n">qobject_cast</span><span style="color: #aa2211"><</span><span class="n">KIO</span><span style="color: #aa2211">::</span><span class="n">CopyJob</span> <span style="color: #aa2211">*></span><span class="p">(</span><span class="n">job</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">this</span><span style="color: #aa2211">-></span><span class="n">addSubjob</span><span class="p">(</span><span class="n">KIO</span><span style="color: #aa2211">::</span><span class="n">del</span><span class="p">(</span><span class="n">copyJob</span><span style="color: #aa2211">-></span><span class="n">currentDestUrl</span><span class="p">(),</span> <span class="n">JobFlag</span><span style="color: #aa2211">::</span><span class="n">HideProgressInfo</span><span class="p">));</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Since you don't test the result of the cast (I assume because by construction only a CopyJob is connected to this slot?), just use static_cast.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10635#inline-50560" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">dropjob.cpp:564</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="n">KIO</span><span style="color: #aa2211">::</span><span class="n">CopyJob</span> <span style="color: #aa2211">*</span><span class="n">copyJob</span> <span style="color: #aa2211">=</span> <span class="n">qobject_cast</span><span style="color: #aa2211"><</span><span class="n">KIO</span><span style="color: #aa2211">::</span><span class="n">CopyJob</span> <span style="color: #aa2211">*></span><span class="p">(</span><span class="n">job</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">this</span><span style="color: #aa2211">-></span><span class="n">addSubjob</span><span class="p">(</span><span class="n">KIO</span><span style="color: #aa2211">::</span><span class="n">del</span><span class="p">(</span><span class="n">copyJob</span><span style="color: #aa2211">-></span><span class="n">currentDestUrl</span><span class="p">(),</span> <span class="n">JobFlag</span><span style="color: #aa2211">::</span><span class="n">HideProgressInfo</span><span class="p">));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">return</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">this-> isn't really useful, I'd remove it</p></div></div></div></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/D10635" rel="noreferrer">https://phabricator.kde.org/D10635</a></div></div><br /><div><strong>To: </strong>meven, dfaure<br /><strong>Cc: </strong>ltoscano, ngraham, Frameworks, michaelh<br /></div>