Skip to content

Commit

Permalink
[core] Save open documents backup file per-user to avoid data loss wh…
Browse files Browse the repository at this point in the history
…en running as root or with two users on same machine
  • Loading branch information
jcelerier committed Oct 26, 2023
1 parent 8326232 commit 252559b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lib/core/application/OpenDocumentsFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ namespace score
{
QString OpenDocumentsFile::path()
{
static QString path = []() -> QString {
auto paths = QStandardPaths::standardLocations(QStandardPaths::TempLocation);
return paths.first() + "/score_open_docs";
static const QString path = []() -> QString {
static const auto username = []() -> QString {
auto username = qEnvironmentVariable("USER");
if(username.isEmpty())
username = qEnvironmentVariable("USERNAME");
return username;
}();
const auto paths = QStandardPaths::standardLocations(QStandardPaths::TempLocation);
return paths.first() + "/score_open_docs." + username;
}();

return path;
Expand Down

0 comments on commit 252559b

Please sign in to comment.