<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/D29485">View Revision</a></tr></table><br /><div><div><p>Good idea overall.</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/D29485#inline-169149">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:430</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: #aa4000">if</span> <span class="p">(</span><span style="color: #aa2211">!</span><span class="n">m_privilegeExecutionEnabled</span> <span style="color: #aa2211">&&</span> <span style="color: #aa2211">!</span><span class="n">isWritable</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span style="color: #74777d">// In copy-as mode, we want to check the directory to which we're copying.</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span style="color: #74777d">// The target file or directory does not exist yet.</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Here you kept a comment that said "we want to check", but the check already happened.<br />
I'd say just remove the two lines of comments.<br />
The code is clearer without them.</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/D29485#inline-169150">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:433</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: #aa4000">const</span> <span class="n">QUrl</span> <span class="n">dest</span> <span style="color: #aa2211">=</span> <span class="n">m_asMethod</span> <span style="color: #aa2211">?</span> <span class="n">m_dest</span><span class="p">.</span><span class="n">adjusted</span><span class="p">(</span><span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">RemoveFilename</span><span class="p">)</span> <span style="color: #aa2211">:</span> <span class="n">m_dest</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span style="color: #aa4000">const</span> <span class="n">QString</span> <span class="n">path</span> <span style="color: #aa2211">=</span> <span class="n">dest</span><span class="p">.</span><span class="n">isLocalFile</span><span class="p">()</span> <span style="color: #aa2211">?</span> <span class="n">dest</span><span class="p">.</span><span class="n">toLocalFile</span><span class="p">()</span> <span style="color: #aa2211">:</span> <span class="n">dest</span><span class="p">.</span><span class="n">toString</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; ">                <span class="n">q</span><span style="color: #aa2211">-></span><span class="n">setError</span><span class="p">(</span><span class="n">ERR_WRITE_ACCESS_DENIED</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">That is not a path, for remote URLs. I suggest using dest.toDisplayString(QUrl::PreferLocalFiles) and just inlining that in the setErrorText call.</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/D29485#inline-169151">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:444</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: #aa4000">if</span> <span class="p">(</span><span class="n">m_dest</span><span class="p">.</span><span class="n">isLocalFile</span><span class="p">())</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span style="color: #74777d">// Fast code path, if a dir is already in the kcoredirlister cache and it was e.g.</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I think this check is too early.</p>

<p style="padding: 0; margin: 8px;">UDS_LOCAL_PATH is also set by kio_desktop and kio_remote, for instance.<br />
It's the main point of that entry: to map URLs from kioslaves-that-wrap-the-local-file-system back to local paths.</p>

<p style="padding: 0; margin: 8px;">AFAICS the old code would use UDS_LOCAL_PATH also for non-local-file URLs.</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/D29485#inline-169152">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:445</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: #aa4000">if</span> <span class="p">(</span><span class="n">m_dest</span><span class="p">.</span><span class="n">isLocalFile</span><span class="p">())</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span style="color: #74777d">// Fast code path, if a dir is already in the kcoredirlister cache and it was e.g.</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span style="color: #74777d">// renamed and got UDS_LOCAL_PATH set</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I completely fail to see the relation between this comment and the code.</p>

<p style="padding: 0; margin: 8px;">"If a dir is already in kcoredirlister" is only relevant when calling KCoreDirLister::cachedItemForUrl, but that's not done here.</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/D29485#inline-169155">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:460</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(151, 234, 151, .6);">
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span style="color: #aa4000">const</span> <span class="n">QUrl</span> <span class="n">dest</span> <span style="color: #aa2211">=</span> <span class="n">m_asMethod</span> <span style="color: #aa2211">?</span> <span class="n">m_dest</span><span class="p">.</span><span class="n">adjusted</span><span class="p">(</span><span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">RemoveFilename</span><span class="p">)</span> <span style="color: #aa2211">:</span> <span class="n">m_dest</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">The check for m_dest.isLocalFile() goes here.</p>

<p style="padding: 0; margin: 8px;">Given line 451, maybe it wasn't local initially, and it is now.</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/D29485#inline-169153">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:461</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: #aa4000">const</span> <span class="n">QUrl</span> <span class="n">dest</span> <span style="color: #aa2211">=</span> <span class="n">m_asMethod</span> <span style="color: #aa2211">?</span> <span class="n">m_dest</span><span class="p">.</span><span class="n">adjusted</span><span class="p">(</span><span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">RemoveFilename</span><span class="p">)</span> <span style="color: #aa2211">:</span> <span class="n">m_dest</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span style="color: #aa4000">const</span> <span class="n">QString</span> <span class="n">path</span> <span style="color: #aa2211">=</span> <span class="n">dest</span><span class="p">.</span><span class="n">toLocalFile</span><span class="p">();</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Now *this* is where the comment about "we want to check..." belongs :-)</p>

<p style="padding: 0; margin: 8px;">The explanation of why we go "up" in case of copyAs, in order not to confuse KDiskFreeSpaceInfo.</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/D29485#inline-169154">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:465</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">// Check available free space for local urls</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span class="n">KDiskFreeSpaceInfo</span> <span class="n">freeSpaceInfo</span> <span style="color: #aa2211">=</span><span class="n">KDiskFreeSpaceInfo</span><span style="color: #aa2211">::</span><span class="n">freeSpaceInfo</span><span class="p">(</span><span class="n">path</span><span class="p">);</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">freeSpaceInfo</span><span class="p">.</span><span class="n">isValid</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;">missing space after =</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/D29485#inline-169158">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:478</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 do this here before statCurrentSrc() is called in the lambda connected to</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span style="color: #74777d">// FileSystemFreeSpaceJob below</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">The lambda is called after going back to the event loop, so this will have happened anyway, no?<br />
I don't get it.</p>

<p style="padding: 0; margin: 8px;">On the other hand I'm fine if this is done here, I'm just not sure why the comment says it has to be so.</p>

<p style="padding: 0; margin: 8px;">(Easy solution is to remove that comment, especially given the suggestion below it won't even seem weird to do things in this order)</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/D29485#inline-169156">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:485</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">// TODO: find a way to report connection errors to the user</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 style="color: #aa2211">!</span><span class="n">m_dest</span><span class="p">.</span><span class="n">isLocalFile</span><span class="p">())</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">const</span> <span class="n">QUrl</span> <span class="n">dest</span> <span style="color: #aa2211">=</span> <span class="n">m_asMethod</span> <span style="color: #aa2211">?</span> <span class="n">m_dest</span><span class="p">.</span><span class="n">adjusted</span><span class="p">(</span><span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">RemoveFilename</span><span class="p">)</span> <span style="color: #aa2211">:</span> <span class="n">m_dest</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Maybe you can move the if (m_dest.isLocalFile()) block here, and use <tt style="background: #ebebeb; font-size: 13px;">else</tt>.<br />
It'll be clearer that free space check happens in both cases.</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/D29485#inline-169157">View Inline</a><span style="color: #4b4d51; font-weight: bold;">copyjob.cpp:486</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: #aa4000">if</span> <span class="p">(</span><span style="color: #aa2211">!</span><span class="n">m_dest</span><span class="p">.</span><span class="n">isLocalFile</span><span class="p">())</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">const</span> <span class="n">QUrl</span> <span class="n">dest</span> <span style="color: #aa2211">=</span> <span class="n">m_asMethod</span> <span style="color: #aa2211">?</span> <span class="n">m_dest</span><span class="p">.</span><span class="n">adjusted</span><span class="p">(</span><span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">RemoveFilename</span><span class="p">)</span> <span style="color: #aa2211">:</span> <span class="n">m_dest</span><span class="p">;</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">FileSystemFreeSpaceJob</span> <span style="color: #aa2211">*</span><span class="n">spaceJob</span> <span style="color: #aa2211">=</span> <span class="n">KIO</span><span style="color: #aa2211">::</span><span class="n">fileSystemFreeSpace</span><span class="p">(</span><span class="n">dest</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">... and this line is the same in both code paths, so it could be extracted to before the if().</p>

<p style="padding: 0; margin: 8px;">To avoid confusion between dest and m_dest, maybe rename this var to destToCheck ?</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/D29485">https://phabricator.kde.org/D29485</a></div></div><br /><div><strong>To: </strong>ahmadsamir, Frameworks, dfaure, meven, sitter<br /><strong>Cc: </strong>ngraham, kde-frameworks-devel, LeGast00n, cblack, michaelh, bruns<br /></div>