diff options
Diffstat (limited to 'common/definitions.cpp')
-rw-r--r-- | common/definitions.cpp | 40 |
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 | ||
26 | static bool rereadDataLocation = true; | ||
27 | static bool rereadConfigLocation = true; | ||
28 | static bool rereadTemporaryFileLocation = true; | ||
29 | |||
30 | void Sink::clearLocationCache() | ||
31 | { | ||
32 | rereadDataLocation = true; | ||
33 | rereadConfigLocation = true; | ||
34 | rereadTemporaryFileLocation = true; | ||
35 | } | ||
36 | |||
26 | QString Sink::storageLocation() | 37 | QString Sink::storageLocation() |
27 | { | 38 | { |
28 | return dataLocation() + "/storage"; | 39 | return dataLocation() + "/storage"; |
@@ -30,26 +41,37 @@ QString Sink::storageLocation() | |||
30 | 41 | ||
31 | QString Sink::dataLocation() | 42 | QString 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 | ||
37 | QString Sink::configLocation() | 52 | QString 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 | ||
43 | QString Sink::temporaryFileLocation() | 62 | QString 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 | ||
55 | QString Sink::resourceStorageLocation(const QByteArray &resourceInstanceIdentifier) | 77 | QString Sink::resourceStorageLocation(const QByteArray &resourceInstanceIdentifier) |