martinrotter / rssguard

Feed reader (and podcast player) which supports RSS/ATOM/JSON and many web-based feed services.
GNU General Public License v3.0
1.64k stars 125 forks source link

[FR]: Move the QWebEngine data path to the data directory when running in portable mode #1496

Closed MatejKafka closed 1 month ago

MatejKafka commented 2 months ago

Brief description of the feature request

On Windows, RSS Guard offers a portable mode, which stores data in data4 in the app directory. However, Qt still creates some data and cache directories in AppData – most of them can be disabled or redirected externally using environment variables (QT_DISABLE_SHADER_DISK_CACHE, QT3D_WRITABLE_CACHE_PATH, QML_DISK_CACHE_PATH), except for browser data from QWebEngine, which is stored in AppData/Roaming/RSS Guard/QtWebEngine.

According to the docs, you should be able to override the paths used by QtWebEngine by using https://doc.qt.io/qt-6/qwebengineprofile.html#setCachePath and https://doc.qt.io/qt-6/qwebengineprofile.html#setPersistentStoragePath. Could you please move these directories to the portable data directory (data4 by default)? This would make RSS Guard a fully portable app, in the sense that no data is stored outside the configured data directory.

martinrotter commented 1 month ago

I just double-checked.

RSS Guard does use "cachePath" and "persistentStoragePath" already.

https://github.com/martinrotter/rssguard/blob/master/src/librssguard/miscellaneous/application.cpp#L249

Double-tested with latest RSS Guard -> no "RSS Guard" folder is created in "Roaming" folder, all relevant cache/web folders are created under "data4" folder as expected. Cannot reproduce your problem, sorry.

MatejKafka commented 1 month ago

I can reproduce the issue in a clean Windows Sandbox instance on Windows 10 22H2 by running the following PowerShell script:

curl.exe -L https://github.com/martinrotter/rssguard/releases/download/4.7.3/rssguard-4.7.3-a4e20486b-win10.7z --output rssguard.7z
curl.exe https://www.7-zip.org/a/7zr.exe --output 7zr.exe
.\7zr.exe x .\rssguard.7z -orssguard

.\rssguard\rssguard.exe

sleep 3
ls -Recurse "$env:APPDATA\RSS Guard\" # this prints some subdirectories, which should not be created
martinrotter commented 1 month ago

Wait, provide log (--log option) file from that workflow.

MatejKafka commented 1 month ago

I spent some time spelunking in the Qt sources; apparently, constructing QWebEngineProfile results in creating ProfileQt, which internally calls ProfileAdapter::ensureDataPathExists, which creates the directory in AppData before you can set the correct data path.

I can reproduce the issue with the following code:

#include <QApplication>
#include <QWebEngineView>
#include <QWebEngineProfile>

int main(int argc, char* argv[]) {
    QCoreApplication::setApplicationName("MyApp");
    auto app = QApplication{argc, argv};

    auto view = QWebEngineView{};
    auto profile = QWebEngineProfile{"MyProfile"};
    profile.setPersistentStoragePath(R"(custom_path\data)");
}

I'll open an issue in https://github.com/qt/qtwebengine, maybe someone will know about a workaround.

MatejKafka commented 1 month ago

opened: https://bugreports.qt.io/browse/QTBUG-129620