summaryrefslogtreecommitdiffstats
path: root/common/definitions.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-20 14:45:16 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-20 14:45:16 +0200
commit75d51b5ee87f3c1d34586c34f73c2100d09e1d04 (patch)
tree9ada52f0b6ccb549c1f80c504cbb7dedb401f1f0 /common/definitions.cpp
parent524e405f645edb6231f9b16fafc1f9ca36af8237 (diff)
downloadsink-75d51b5ee87f3c1d34586c34f73c2100d09e1d04.tar.gz
sink-75d51b5ee87f3c1d34586c34f73c2100d09e1d04.zip
Reread the location if we enable the test mode
Diffstat (limited to 'common/definitions.cpp')
-rw-r--r--common/definitions.cpp40
1 files changed, 31 insertions, 9 deletions
diff --git a/common/definitions.cpp b/common/definitions.cpp
index 7f4fbbe..17977bc 100644
--- a/common/definitions.cpp
+++ b/common/definitions.cpp
@@ -23,6 +23,17 @@
23#include <QStandardPaths> 23#include <QStandardPaths>
24#include <QDir> 24#include <QDir>
25 25
26static bool rereadDataLocation = true;
27static bool rereadConfigLocation = true;
28static bool rereadTemporaryFileLocation = true;
29
30void Sink::clearLocationCache()
31{
32 rereadDataLocation = true;
33 rereadConfigLocation = true;
34 rereadTemporaryFileLocation = true;
35}
36
26QString Sink::storageLocation() 37QString Sink::storageLocation()
27{ 38{
28 return dataLocation() + "/storage"; 39 return dataLocation() + "/storage";
@@ -30,26 +41,37 @@ QString Sink::storageLocation()
30 41
31QString Sink::dataLocation() 42QString Sink::dataLocation()
32{ 43{
33 static auto location = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink"; 44 static QString location;
45 if (rereadDataLocation) {
46 location = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink";
47 rereadDataLocation = false;
48 }
34 return location; 49 return location;
35} 50}
36 51
37QString Sink::configLocation() 52QString Sink::configLocation()
38{ 53{
39 static auto location = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/sink"; 54 static QString location;
55 if (rereadConfigLocation) {
56 location = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/sink";
57 rereadConfigLocation = false;
58 }
40 return location; 59 return location;
41} 60}
42 61
43QString Sink::temporaryFileLocation() 62QString Sink::temporaryFileLocation()
44{ 63{
45 static auto path = dataLocation() + "/temporaryFiles"; 64 static QString location;
46 static bool initialized = false; 65 static bool dirCreated = false;
47 if (!initialized) { 66 if (rereadTemporaryFileLocation) {
48 if (QDir{}.mkpath(path)) { 67 location = dataLocation() + "/temporaryFiles";
49 initialized = true; 68 dirCreated = QDir{}.mkpath(location);
50 } 69 rereadTemporaryFileLocation = false;
51 } 70 }
52 return path; 71 if (!dirCreated && QDir{}.mkpath(location)) {
72 dirCreated = true;
73 }
74 return location;
53} 75}
54 76
55QString Sink::resourceStorageLocation(const QByteArray &resourceInstanceIdentifier) 77QString Sink::resourceStorageLocation(const QByteArray &resourceInstanceIdentifier)