Skip to content

Commit

Permalink
inventory: use standard AppDataLocation for model files
Browse files Browse the repository at this point in the history
This puts the models in $XDG_DATA_DIR/translateLocally on Linux,
or equivalent user data directories on other platforms.

This avoids putting relatively large files in the config directory,
which may be versioned for user dotfiles.

Github: closes #139
  • Loading branch information
pacien committed Aug 24, 2023
1 parent 4988afc commit 0c0bc18
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/inventory/ModelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QDirIterator>
#include <QFile>
#include <QSaveFile>
#include <QStandardPaths>
#include <QFileInfo>
#include <QJsonDocument>
#include <QJsonObject>
Expand Down Expand Up @@ -77,9 +78,7 @@ ModelManager::ModelManager(QObject *parent, Settings * settings)
, settings_(settings)
, isFetchingRemoteModels_(false)
{
// Create/Load Settings and create a directory on the first run. Use mock QSEttings, because we want nativeFormat, but we don't want ini on linux.
// NativeFormat is not always stored in config dir, whereas ini is always stored. We used the ini format to just get a path to a dir.
appDataDir_ = QFileInfo(QSettings(QSettings::IniFormat, QSettings::UserScope, "translateLocally", "translateLocally").fileName()).absoluteDir();
appDataDir_ = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
if (!QDir(appDataDir_).exists()) {
if (QFileInfo::exists(appDataDir_.absolutePath())) {
std::cerr << "We want to store data at a directory at: " << appDataDir_.absolutePath().toStdString() << " but a file with the same name exists." << std::endl;
Expand Down

0 comments on commit 0c0bc18

Please sign in to comment.