Diffusion Baloo 9b0ecc5d41b0

[PendingFileQueue] Avoid delete + create / create + delete race

Authored by bruns on Jun 9 2019, 7:36 PM.

Description

[PendingFileQueue] Avoid delete + create / create + delete race

Summary:
When the 'delete' flag is set, the file was removed from the index and
the item was removed from the pending file queue (m_cache). When a
'created' event arrives before the queue has been processed, the flag
was merged into the queue item, but never processed (delete + create),
i.e. the file was omitted from the index.

In case a created/modified file was moved to the m_pendingFiles queue
(files to be reindexed later) and deleted, the pending files timer may
fire before process is run, and the indexNewFile/indexModifiedFile
signal is emitted for a no longer existing file. Although this is handled
in the indexer, this causes unnecessary work.

Emit the removeFileIndex immediately and remove the file from all
queues.

A deleted file/folder is kept in the m_recentlyEmitted list, to avoid
excessive events when e.g. a temporary file is created/deleted in short
period of time.

Test Plan:
$> date > testfile; rm testfile; date > testfile
After the change, testfile is included in the index

$> date > testfile; date > testfile2; usleep 2000; rm testfile
After the change, indexNewFile signal is emitted only for testfile2,
while for testfile removeFileIndex is emitted.

Reviewers: Baloo, ngraham, astippich, poboiko

Reviewed By: Baloo, ngraham

Subscribers: kde-frameworks-devel

Tags: Frameworks, Baloo

Differential Revision: https://phabricator.kde.org/D21709

Details