Introduce sanitizer class
ClosedPublic

Authored by michaelh on Mar 13 2018, 2:15 PM.

Details

Summary

Due to device ids being inconstant duplicates are introduced to the database. I. e. multiple document ids pointing to the same entity.
This class shall eventually sanitize the database. Currently it just displays the issues should there be any.

Diff Detail

Repository
R293 Baloo
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
michaelh created this revision.Mar 13 2018, 2:15 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptMar 13 2018, 2:15 PM
michaelh requested review of this revision.Mar 13 2018, 2:15 PM
ngraham accepted this revision.Mar 14 2018, 7:03 PM
ngraham added a subscriber: ngraham.

Looks good to me!

This revision is now accepted and ready to land.Mar 14 2018, 7:03 PM
michaelh added inline comments.Mar 14 2018, 7:57 PM
src/engine/databasesanitizer.cpp
201

This is the best I could think of to make getDocuments accessible to DatabaseSanitizerImpl. But I don't like it.
This method definitely should not be part of the interface.

mlaurent requested changes to this revision.Mar 15 2018, 9:12 AM
mlaurent added a subscriber: mlaurent.
mlaurent added inline comments.
src/engine/databasesanitizer.cpp
45

initialize value by default please

108

includeIds.count() > 0 => use !isEmpty

154

const QSharedPointer<QRegularExpression> &
------------------------------------------------------^

166

use qCDebug(BALOO)

175

as you add a i18n in engine directory you need to extract them.
you missed to add a Message.sh in this subdirectory and loading message file.

This revision now requires changes to proceed.Mar 15 2018, 9:12 AM

Is it possible to create an autotest for this class ?

michaelh updated this revision to Diff 29594.Mar 15 2018, 1:24 PM
  • Apply suggested changes
  • Put method descriptions in their correct place
michaelh marked 4 inline comments as done.Mar 15 2018, 1:42 PM

There were some conflicts I had to solve with this. Because it is not completely clear to me where this is going I wanted to be safe and used a d-pointer.
As a consequence this class does the printing which I prefer to be in the cli.
Secondly I can't make DatabaseSanitizerImpl a friend of the Transaction class. Which leads to the getDocuments() in DatabaseSanitizer, which should not be part of the interface. In the future more of similar functions will be needed.
Is there a better way to accomplish this?

src/engine/databasesanitizer.cpp
166

I get a linker error
databasesanitizer.cpp:189: undefined reference to BALOO()'`
Currently its not worth the trouble fixing it, because that method is going to change anyway.
Also I don't like to mix debug statement and printing to stderr.

Is it possible to create an autotest for this class ?

This is where it gets complicated.
Essentially I can test only for sane databases, but that's useless.
Or I need to mock an external drive and have control over its device id, which seems to be very difficult if at all possible.

michaelh added inline comments.Mar 15 2018, 1:51 PM
src/engine/databasesanitizer.cpp
164

Before landing this will become

Create a list of \a FileInfo items and print it to stdout.
mlaurent requested changes to this revision.Mar 16 2018, 1:54 PM
mlaurent added inline comments.
src/engine/databasesanitizer.cpp
47

you can replace this constructor by initialize directly variable

> bool accessible = true;

etc.

> it avoids to create this constructor

100

const auto & for a quint32
it's better to use directly quint32 without const'ref

This revision now requires changes to proceed.Mar 16 2018, 1:54 PM
michaelh updated this revision to Diff 29683.Mar 16 2018, 2:43 PM
  • Turn FileInfo into a struct again
michaelh marked 3 inline comments as done.Mar 16 2018, 2:44 PM
mlaurent accepted this revision.Mar 16 2018, 2:52 PM

+2 for me but I don't know baloo code :)

This revision is now accepted and ready to land.Mar 16 2018, 2:52 PM
This revision was automatically updated to reflect the committed changes.