Make this test work again with new uds implementation
ClosedPublic

Authored by jtamate on Jun 30 2018, 3:40 PM.

Details

Summary

With the new uds implementation, when some data is meant to replace an old one, it has to use replace() instead of insert() to avoid an assert of data already exists.
Use 3 different entries and only insert().

Test Plan

before: crash in the uds assert
after: passes the test

Diff Detail

Repository
R318 Dolphin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jtamate created this revision.Jun 30 2018, 3:40 PM
Restricted Application added a project: Dolphin. · View Herald TranscriptJun 30 2018, 3:40 PM
Restricted Application added a subscriber: kfm-devel. · View Herald Transcript
jtamate requested review of this revision.Jun 30 2018, 3:40 PM
jtamate added a dependent revision: D13814: Speedup sort.

Will it still work if we link against an old kio version?

bruns added a subscriber: bruns.Jul 1 2018, 12:31 AM

@jtamate , can you please use arc diff to upload patches - arc sucks, but having no patch context sucks even more ...

jtamate updated this revision to Diff 36975.Jul 1 2018, 5:36 AM

Updated the patch with context.

It will not work with kio previous to 5.47, unless there is a way to check the kio version at compile time or runtime.

jtamate updated this revision to Diff 36976.Jul 1 2018, 5:55 AM
jtamate edited the summary of this revision. (Show Details)

Use 3 entries instead of replace().
Now it will work with any kio version.

elvisangelaccio requested changes to this revision.Jul 1 2018, 8:19 PM

Updated the patch with context.

It will not work with kio previous to 5.47, unless there is a way to check the kio version at compile time or runtime.

There is, but maybe a better idea is to bump the minimum required version of KIO at 5.47 (I'm assuming the new UDS implementation is worth having it?)

This revision now requires changes to proceed.Jul 1 2018, 8:19 PM

FWIW, I'd be okay with bumping the minimum KIO version to 5.47 in master.

aacid added a subscriber: aacid.Jul 2 2018, 10:54 PM

Did we break how KIO works and we're now going after the users of KIO and fixing them or was this a "bad usage" from starters that worked by chance?

Did we break how KIO works and we're now going after the users of KIO and fixing them or was this a "bad usage" from starters that worked by chance?

We break how KIO works and we're now going after the users of KIO and fixing them.
uds insert() is now only for insert, replace() is for insert or update. Since https://phabricator.kde.org/D12696

bruns added inline comments.Jul 3 2018, 3:45 PM
src/tests/kfileitemmodeltest.cpp
1562

if you move the insert(UDS_NAME, ...) and insert(UDS_USER, ...) in front of the loop, you can call items.append(entry[i]...) inside the loop.

jtamate updated this revision to Diff 37119.Jul 3 2018, 5:49 PM
jtamate retitled this revision from make this test work again with new uds implementation to Make this test work again with new uds implementation.
jtamate edited the summary of this revision. (Show Details)

Call items.append inside the loop.

aacid added a subscriber: dfaure.Jul 3 2018, 10:00 PM

Did we break how KIO works and we're now going after the users of KIO and fixing them or was this a "bad usage" from starters that worked by chance?

We break how KIO works and we're now going after the users of KIO and fixing them.
uds insert() is now only for insert, replace() is for insert or update. Since https://phabricator.kde.org/D12696

@dfaure Are you aware we broke KIO backwards compatibility? Seems like we threw out of the window our compatibility promises for our of most important frameworks and really I don't understand why we did that in the sake of performance. If the performance boost was so great we could have introduced V2 classes and make people start using them, but breaking people's code seems really bad to me :/

dfaure added a comment.Jul 4 2018, 7:47 PM

Albert, you are of course fully right.

My reasoning was "in practice, [outside of strangely written tests such as the one here], there is zero reason to replace entries in a UDSEntry. All kioslaves either create a new UDSEntry for every file, or do reuse it after calling clear(). And people use if() statements rather than overwriting what they just wrote for the same file, which would be rather inefficient.". And indeed I just checked a lot of kioslaves and they do that.

But ForwardingSlaveBase::prepareUDSEntry in KIO itself, uses insert() to replace UDS_URL, and in fact all of ForwardingSlaveBase should use replace(), as well as users of ForwardingSlaveBase like kio_desktop.
That is troublesome indeed.

The naming is the problem. Naming aside, the old method should still insert-or-replace and some new method should insert-only, but how to call that in a nice way other than insert, especially when 90% of the code out there should ONLY use that? Hmm, fastInsert?

Then if we have fastInsert() and replace(), we can have a deprecated insert() that calls replace().

But ForwardingSlaveBase::prepareUDSEntry in KIO itself, uses insert() to replace UDS_URL, and in fact all of ForwardingSlaveBase should use replace(), as well as users of ForwardingSlaveBase like kio_desktop.

In ForwardingSlaveBase::prepareUDSEntry, it uses insert() only to insert an UDS URL, because it is done only if the UDS URL is empty, isn't it?
But for UDS_LOCAL_PATH, I guess you're right, it should use replace().

dfaure added a comment.Jul 4 2018, 8:35 PM

But ForwardingSlaveBase::prepareUDSEntry in KIO itself, uses insert() to replace UDS_URL, and in fact all of ForwardingSlaveBase should use replace(), as well as users of ForwardingSlaveBase like kio_desktop.

In ForwardingSlaveBase::prepareUDSEntry, it uses insert() only to insert an UDS URL, because it is done only if the UDS URL is empty, isn't it?
But for UDS_LOCAL_PATH, I guess you're right, it should use replace().

No, it replaces the URL if it was found, i.e. not empty.

In any case, can you first restore compat?

@jtamate Any updates on this? Can you use the new fastInsert() calls here?

@jtamate Any updates on this? Can you use the new fastInsert() calls here?

Not until dolphin depends on KIO 5.47, currently its minimum required kio version is 5.43.

But it could land as it is and be ready for just change insert by fastInsert when it depends on that kio version.

elvisangelaccio accepted this revision.Aug 16 2018, 10:33 AM

Right. Then let's ship it as is for now, thanks!

This revision is now accepted and ready to land.Aug 16 2018, 10:33 AM
Closed by commit R318:2104d18a6760: Make this test work again with new uds implementation (authored by Travis CI Bot <travis@travis-ci.org>). · Explain WhyAug 16 2018, 11:06 AM
This revision was automatically updated to reflect the committed changes.
cfeck added a subscriber: cfeck.Aug 16 2018, 11:10 AM

Authored by a Bot?

Authored by a Bot?

Yeah I was about to ask the same question.

@bshah @bcooksley @nalvarez ?

Authored by a Bot?

Somehow my name and email address in .gitconfig got changed. How? No idea.
Should revert and push again with the right name?

elvisangelaccio added a comment.EditedAug 16 2018, 11:44 AM

Authored by a Bot?

Somehow my name and email address in .gitconfig got changed. How? No idea.
Should revert and push again with the right name?

Ah ok. I thought this had something to do with the CI integration on phabricator.

Then yes, a revert+push is good enough imho.

That would have happened locally, shouldn't be anything to do with our systems - especially given it's a Travis CI name/address being mentioned.