Bug 413588 - always inserts file:// into path
Summary: always inserts file:// into path
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: Maildir Resource (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-29 10:44 UTC by lists
Modified: 2020-03-01 18:44 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lists 2019-10-29 10:44:56 UTC
SUMMARY

when creating a local storage or invoking local folders, there are silly paths entered. It messes up filters and inboxfolders for accounts.

fisrtly
~./file is created - what for? why.
in there reside some resources, which is still ok, but then i experience this structure in one of my subfolders see below.




STEPS TO REPRODUCE
1. dont know - happens on every clean setup of 19.08
2.
3. 

OBSERVED RESULT


./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp
./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp/file:
./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp/file:/home
./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp/file:/home/holger
./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp/file:/home/holger/.local
./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp/file:/home/holger/.local/share
./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp/file:/home/holger/.local/share/akonadi_maildir_resource_0
./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail
./file:/home/holger/.local/share/akonadi_maildir_resource_0/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp/file:/home/holger/.local/share/akonadi_maildir_resource_0/sent-mail/tmp

then moving files or applying filters goes nuts. All Locations being reset and no longer found. akonadictl restart/kmail2 restart gives new suggestions of paths/finds other.
ATM kmail/akonadi is unusable for me.

EXPECTED RESULT:
not doubling paths and clean correct location.


SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Gentoo Plasma 19.08
Comment 1 lists 2019-10-29 10:47:40 UTC
just found a weirder file construction in my setup:

from an old import path all mixed up:

/file:/home/holger/.local/share/akonadi_maildir_resource_0/.191028.directory/.KMail-Import.directory/.Lokal.directory/Tommy-router/cur/file:/home/holger/.local/share/akonadi_maildir_resource_0/.191028.directory/.KMail-Import.directory/.Lokal.directory/Tommy-router/cur
Comment 2 Igor Poboiko 2020-03-01 18:44:59 UTC
Git commit 93ecfacfb9f21ee027dbcfc7d5d47ddbbb253ba1 by Igor Poboiko.
Committed on 01/03/2020 at 18:44.
Pushed by poboiko into branch 'master'.

[resources/maildir] Don't save "file:" schema to the config

Summary:
`ConfigWidget` uses `KConfig` underneath, and utilizes `KUrlRequester` custom
widget. The `USER` property of this widget (which is used by `KConfig`) is of
type `QUrl`, and thus when dialog is accepted, the `path` config property
gets overriden with `QUrl::toString()` value, which prepends `file:` schema
(this is basically because `KCoreConfigSkeleton::ItemPath` is inherited from
`ItemString`, and when someone calls `ItemString::setProperty`, it gets
casted as `QVariant::toString`).

Inside the `ConfigWidget::save` the code calls `setPath` method on
`url.toLocalFile`, which drops the scheme. Because of that, the `pathItem`
and `path` property of `mSettings` have different values, first has schema
and the second hasn't. Eventually, the value stored by `pathItem` wins, and
`mSettings->path()` returns URL with schema. However, `Maildir` doesn't expect
it and misinterprets it as the relative path to current WORKDIR (which is home
directory), thus creating `/home/user/file:/home/user/...` file structure.

The proposed solution is to simply call `mSettings->save()`, which overrides
`pathItem` value and drops schema from it.

It also fixes the `AkoNotes` resource, which uses the same `ConfigWidget`.
Funny enough, `Contacts` resource, which is somewhat similar, is not affected
as it has the same `Settings->save()` call.

Alternative approaches include:
1) Teach `Maildir` to drop the schema (if it's there).
2) Teach `KCoreConfigSkeleton::ItemPath` to work with `QUrl` and don't append
schema (it makes sense, because `ItemPath` corresponds to local file. Although
it's not documented that it shouldn't have schema, it seems from the tests that
it was the original intent). This could save the headache of having such issue
in the future, but it could mess up with other programs in funny ways (as
currently `file:` sometimes gets prepended, and some code might implicitly rely
on it)

Additional note:
There are `ui.kcfg_Path->url().isLocalFile()` checks around, which doesn't make
sense to me, as `KUrlRequester` is used for local files and it seems like it
always returns `QUrl` pointing to local file (i.e. have the `file:` schema).
Related: bug 408354, bug 411269

Test Plan:
1) Open `akonadiconsole -> Local Folders` properties, change the folder, save
2) `cat ~/.config/akonadi_maildir_resource_0rc`. `file:` schema gets prepended
2.1) `akonadictl restart`. `file:` folder gets created inside homedir
3) Apply patch, repeat (1)-(2.1). `file:` schema is dropped.

Reviewers: dvratil, mlaurent

Reviewed By: dvratil

Subscribers: kde-pim

Tags: #kde_pim

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

M  +1    -0    resources/maildir/configwidget.cpp

https://commits.kde.org/kdepim-runtime/93ecfacfb9f21ee027dbcfc7d5d47ddbbb253ba1