<table><tr><td style="">poboiko updated this revision to Diff 50832.<br />poboiko edited the summary of this revision. <a href="https://phabricator.kde.org/transactions/detail/PHID-XACT-DREV-k2ico5jewppbx7m/">(Show Details)</a><br />poboiko added a comment.
</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/D18698">View Revision</a></tr></table><br /><div><div><p>Explained the race condition in summary, expanded test to check if watches were installed correctly.</p>

<p>I've encountered some pretty weird issue: the watch for the moved folder is not installed; but it is installed for all its subfolders.<br />
The reason is that <tt style="background: #ebebeb; font-size: 13px;">it.fileInfo()</tt> returns empty <tt style="background: #ebebeb; font-size: 13px;">QFileInfo()</tt> for the moved folder. But it works fine for all the subentries.<br />
That is not the issue with the previous version, because <tt style="background: #ebebeb; font-size: 13px;">KInotify::addWatch</tt> doesn't check for <tt style="background: #ebebeb; font-size: 13px;">fileInfo().isDir()</tt> explicitly: it just relies on <tt style="background: #ebebeb; font-size: 13px;">DirsOnly</tt> flag for the iterator.</p>

<p>There is a workaround: if I create <tt style="background: #ebebeb; font-size: 13px;">QFileInfo</tt> by hand, using <tt style="background: #ebebeb; font-size: 13px;">QFileInfo fi(it.filePath())</tt> instead of <tt style="background: #ebebeb; font-size: 13px;">it.fileInfo()</tt>, everything seems to be working fine.<br />
(the test fails if I use <tt style="background: #ebebeb; font-size: 13px;">it.fileInfo()</tt>, but it passes if I use this workaround)</p></div></div><br /><div><strong>CHANGES TO REVISION SUMMARY</strong><div><div style="white-space: pre-wrap; color: #74777D;"><div style="padding: 8px 0;">...</div> # If we move folder from another device, `Inotify` doesn't create `Move` signal, but `Create` instead, which seems to be handled properly <br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">(</span>I'm not really sure why, because it smells like a race condition here. <br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">If i.e.</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">Assume user moves `folder/` with `folder/file1` and `folder/file2` files inside it. If the things happen in a following order:<br />
 # We receive `Create` signal for inotify<br />
 # `folder/file1` is moved<br />
</span> <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">we got `Create` signal -> then `file1` gets moved -> then we add</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);"># We add inotify</span> watch<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">es -> then `file2` gets moved,</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);"> for `folder/`<br />
</span> <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">information about </span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);"># `folder/</span>file<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">1 should get lost.</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">2` is moved</span><br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">Am I mis</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">then we will receive `Create` signal only for `file2`, lo</span>sing <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">something here?)</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">information concerning `file1` completely.</span><br />
<br />
BUG: 342224</div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R293 Baloo</div></div></div><br /><div><strong>CHANGES SINCE LAST UPDATE</strong><div><a href="https://phabricator.kde.org/D18698?vs=50776&id=50832">https://phabricator.kde.org/D18698?vs=50776&id=50832</a></div></div><br /><div><strong>BRANCH</strong><div><div>add-watch-moved (branched from master)</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D18698">https://phabricator.kde.org/D18698</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>autotests/unit/file/kinotifytest.cpp<br />
src/file/kinotify.cpp</div></div></div><br /><div><strong>To: </strong>poboiko, Baloo, Frameworks, ngraham, bruns<br /><strong>Cc: </strong>bruns, ngraham, kde-frameworks-devel, Baloo, ashaposhnikov, michaelh, astippich, spoorun, abrahams<br /></div>