Skip to content

Conversation

brainrom
Copy link

Fix for #3406 and #7654.

And cookie jar now also stores in StateLocation, because it's app state and not configuration. Added corresponding migration function.

Shouldn't negatively affect Windows and Mac OS, because StateLocation on these platforms are subdirectories of AppConfigLocation.

From Qt doc:

Path type macOS Windows
AppConfigLocation "~/Library/Preferences/<APPNAME>" "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>"
StateLocation "~/Library/Preferences/<APPNAME>/State" "C:/Users/<USER>/AppData/Local/<APPNAME>/State", "C:/ProgramData/<APPNAME>/State"

@brainrom brainrom changed the title logs and cookies moved to state path Chaning directories for logs and state files Feb 17, 2025
@camilasan
Copy link
Member

Shouldn't negatively affect Windows and Mac OS, because StateLocation on these platforms are subdirectories of AppConfigLocation.

Do you have access to Mac and/or Windows to check it?
Could you try adding testing for this change?

@brainrom
Copy link
Author

brainrom commented Feb 27, 2025

Do you have access to Mac and/or Windows to check it?

I can try build and check on Windows, but have absolutely no idea how to build and check on Mac.

Could you try adding testing for this change?

What kind of testing?

@camilasan
Copy link
Member

I can try build and check on Windows, but have absolutely no idea how to build and check on Mac.

On Windows it would already help.

What kind of testing?

Sorry, I mean tests. Unit/code tests.

@brainrom
Copy link
Author

brainrom commented Feb 27, 2025

On Windows it would already help.

Ok, then I'll manually test it on Windows.

Sorry, I mean tests. Unit/code tests.

Nextcloud currently don't have tests for similar things, not configs, nor migration. What exactly should I test? I can make test for tryMigrateCookieJar() method. Create file in old location, test that it moves to the new location, etc.
Btw, should migration overwrite new file in case where old file and new file presents?

@camilasan
Copy link
Member

Sorry I didn't reply before...

I can make test for tryMigrateCookieJar() method. Create file in old location, test that it moves to the new location, etc.

That makes sense.

Btw, should migration overwrite new file in case where old file and new file presents?

You should check if there is a file present before migrating. That is what we do with the config file nextcloud.cfg.

@brainrom brainrom requested a review from camilasan as a code owner April 3, 2025 08:57
@brainrom
Copy link
Author

brainrom commented Apr 3, 2025

Now new file isn't overwritten if already exists. Added test for tryMigrateCookieJar().

Copy link

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Copy link
Collaborator

@mgallien mgallien left a comment

Choose a reason for hiding this comment

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

@brainrom what would happen if we now write the logs to a different folder, what do you do with existing log files ?
are they moved to the new folder ?
can you check if generating a debug archive is still working ?

@brainrom
Copy link
Author

I checked log generation on Linux, it records to ~/.local/state/logs. On MacOS and Windows it should work, because it uses write location and create dirs if it doesn't exist, but I'm unable to test it.

Copy link
Collaborator

@mgallien mgallien left a comment

Choose a reason for hiding this comment

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

@brainrom you cannot change the log location without the migration (as you did with the cookie jar)
see also my other comments

QString ConfigFile::logDir() const
{
const auto defaultLogDir = QString(configPath() + QStringLiteral("/logs"));
const auto defaultLogDir = QString(QStandardPaths::writableLocation(QStandardPaths::StateLocation) + QStringLiteral("/logs"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

before we change the log location, existing log files should be migrated to the new place
otherwise people may loose logs that may be important for them

Copy link
Author

Choose a reason for hiding this comment

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

Is Application::setupLogging() is the good place for log migration routine? Looks like it's entry point for logDir() usage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@brainrom
yes
I think so
sorry for the delay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants