diff options
Diffstat (limited to 'common/definitions.cpp')
-rw-r--r-- | common/definitions.cpp | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/common/definitions.cpp b/common/definitions.cpp index 3fc4700..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,21 +41,37 @@ QString Sink::storageLocation() | |||
30 | 41 | ||
31 | QString Sink::dataLocation() | 42 | QString Sink::dataLocation() |
32 | { | 43 | { |
33 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink"; | 44 | static QString location; |
45 | if (rereadDataLocation) { | ||
46 | location = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink"; | ||
47 | rereadDataLocation = false; | ||
48 | } | ||
49 | return location; | ||
34 | } | 50 | } |
35 | 51 | ||
36 | QString Sink::configLocation() | 52 | QString Sink::configLocation() |
37 | { | 53 | { |
38 | return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/sink"; | 54 | static QString location; |
55 | if (rereadConfigLocation) { | ||
56 | location = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/sink"; | ||
57 | rereadConfigLocation = false; | ||
58 | } | ||
59 | return location; | ||
39 | } | 60 | } |
40 | 61 | ||
41 | QString Sink::temporaryFileLocation() | 62 | QString Sink::temporaryFileLocation() |
42 | { | 63 | { |
43 | auto path = dataLocation() + "/temporaryFiles"; | 64 | static QString location; |
44 | //FIXME create in a singleton on startup? | 65 | static bool dirCreated = false; |
45 | QDir dir; | 66 | if (rereadTemporaryFileLocation) { |
46 | dir.mkpath(path); | 67 | location = dataLocation() + "/temporaryFiles"; |
47 | return path; | 68 | dirCreated = QDir{}.mkpath(location); |
69 | rereadTemporaryFileLocation = false; | ||
70 | } | ||
71 | if (!dirCreated && QDir{}.mkpath(location)) { | ||
72 | dirCreated = true; | ||
73 | } | ||
74 | return location; | ||
48 | } | 75 | } |
49 | 76 | ||
50 | QString Sink::resourceStorageLocation(const QByteArray &resourceInstanceIdentifier) | 77 | QString Sink::resourceStorageLocation(const QByteArray &resourceInstanceIdentifier) |