Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create 'data' subdirectory on Linux #11644

Merged
merged 1 commit into from
Oct 16, 2020
Merged

Don't create 'data' subdirectory on Linux #11644

merged 1 commit into from
Oct 16, 2020

Conversation

lbilli
Copy link
Contributor

@lbilli lbilli commented Dec 12, 2019

Any reason to use on Linux the unusual path

~/.local/share/data/qBittorrent

instead of

~/.local/share/qBittorrent

?

@glassez
Copy link
Member

glassez commented Dec 14, 2019

At least you break existing installations, isn't it?

@FranciscoPombal
Copy link
Member

Upgrade path could be as follows (semi pseudo-code):

IF EXISTS ~/.local/share/data/qBittorrent THEN:
    mkdir -p ~/.local/share/qBittorrent
    mv -t ~/.local/share/qBittorrent/ ~/.local/share/data/qBittorrent/*
  • Pro: better compliance with the XDG Base Directory Specification, since on Ubuntu and most distros $XDG_DATA_HOME is ~/.local/share
  • Con: downgrades from the version that implements this would require manual intervention from the user, to copy everything in ~/.local/share/qBittorrent/ back to ~/.local/share/data/qBittorrent/

@FranciscoPombal
Copy link
Member

FranciscoPombal commented Dec 14, 2019

On second thought, are you sure the code you changed is what makes qBittorrent create the directory in the first place, or just a function called to return what the path actually is, after having been created elsewhere? Especially this comment seems to imply the second option:

// on Linux gods know why qBittorrent creates 'data' subdirectory in ~/.local/share/

EDIT: not a problem, see next post

@Kolcha
Copy link
Contributor

Kolcha commented Dec 14, 2019

I agreed, data folder looks strange, very unusual and even annoying, but I thought it was left for history reasons (compatibility)... but the comment that @FranciscoPombal found made me think "what's really going on?"
I'll investigate it these days and publish results here, this is not a problem for me even if I'll have to dig into Qt' sources "in the search of truth". Fortunately, I have suitable Linux environment for that.

@lbilli
Copy link
Contributor Author

lbilli commented Dec 14, 2019

FYI
I'm running a patched version of qBittorrent on my machine and I don't see any problems.

@Kolcha
Copy link
Contributor

Kolcha commented Dec 14, 2019

Confirmed, modified function returns path which is used everywhere, i.e. first time when folder must be created. data part comes exactly from this function.

@FranciscoPombal
Copy link
Member

Ok, upon a closer look, I can confirm that this patch should work as intended. That place is where, in fact, the directory is set to be created as such.

For anyone interested, here is the full code path:

  1. The application creates an instance of Profile (Profile appears to be a singleton class).
    Profile::initialize(profileDir, m_commandLineArgs.configurationName,
  2. The Profile constructor calls ensureDirectoryExists with the SpecialDiretory::Data parameter
    ensureDirectoryExists(SpecialFolder::Data);
  3. Inside ensureDirectoryExists the following lines sets the path to be created:
    const QString locationPath = location(folder);
  4. Inside the location function this gets called, which is the function that is changed in this patch:
    result = m_profileImpl->dataLocation();
  5. Back in ensureDirectoryExists, the directories actually get created with the location specified previously, and qBitorrent goes about the rest of its business.
    if (!locationPath.isEmpty() && !QDir().mkpath(locationPath))

I would still recommend providing an upgrade path in this PR, as outlined above.

@j1warren
Copy link
Contributor

j1warren commented Jan 1, 2020

I think the right way is to check if 'data' folder exists, then continue using it.
If it doesn't, generate and use the new path without it.

That way no old installations brake, but newer ones and those where people moved it by hand will use cleaner path.
And then somewhere at version 6.0 brake when using 'data' path.

@FranciscoPombal
Copy link
Member

@lbilli If you want this to get merged, you still need to provide an upgrade path, either
#11644 (comment) or #11644 (comment)

@FranciscoPombal FranciscoPombal added Core OS: Linux Issues specific to Linux distributions labels Feb 26, 2020
@lbilli
Copy link
Contributor Author

lbilli commented Feb 26, 2020

@FranciscoPombal
I added the logic to use /data/ if it already exists, as suggested above.
Feel free to modify or improve if necessary.

src/base/private/profile_p.cpp Outdated Show resolved Hide resolved
@NotTsunami
Copy link
Contributor

NotTsunami commented Oct 13, 2020

@lbilli Can you rebase and implement the suggested changes? The file has moved to src/base/profile_p.cpp. It would be nice to see this make it in the upcoming release.

@lbilli
Copy link
Contributor Author

lbilli commented Oct 14, 2020

Rebased and added a warning.
However, I'm not sure what's the best practice to log a warning at this stage when the Logger is not active yet.

@NotTsunami
Copy link
Contributor

@Chocobo1 @glassez I know you hate these pings, but I think this is a good candidate to get in 4.3.x. Can you guys review this please?

Copy link
Member

@glassez glassez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash your commits into one.

src/base/profile_p.cpp Outdated Show resolved Hide resolved
@FranciscoPombal
Copy link
Member

Rebased and added a warning.
However, I'm not sure what's the best practice to log a warning at this stage when the Logger is not active yet.

Oh, yes. I guess the warning is just fine then.

@Chocobo1 Chocobo1 merged commit 152afa7 into qbittorrent:master Oct 16, 2020
@Chocobo1
Copy link
Member

@lbilli
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core OS: Linux Issues specific to Linux distributions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants