From 5adfceae08872b9d7f143d8b9464578fb8e43a69 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 10 Apr 2016 10:55:56 +0200 Subject: Allow clients to request a temporary file for BLOB properties --- common/definitions.cpp | 10 ++++++++++ common/definitions.h | 1 + common/store.cpp | 6 ++++++ common/store.h | 9 +++++++-- 4 files changed, 24 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/definitions.cpp b/common/definitions.cpp index daf354c..101279e 100644 --- a/common/definitions.cpp +++ b/common/definitions.cpp @@ -21,12 +21,22 @@ #include "definitions.h" #include +#include QString Sink::storageLocation() { return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/storage"; } +QString Sink::temporaryFileLocation() +{ + auto path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/temporaryFiles"; + //FIXME create in a singleton on startup? + QDir dir; + dir.mkpath(path); + return path; +} + QByteArray Sink::resourceName(const QByteArray &instanceIdentifier) { auto split = instanceIdentifier.split('.'); diff --git a/common/definitions.h b/common/definitions.h index 96ec27e..a90b15a 100644 --- a/common/definitions.h +++ b/common/definitions.h @@ -26,5 +26,6 @@ namespace Sink { QString SINK_EXPORT storageLocation(); +QString SINK_EXPORT temporaryFileLocation(); QByteArray SINK_EXPORT resourceName(const QByteArray &instanceIdentifier); } diff --git a/common/store.cpp b/common/store.cpp index 4bf1c58..700263b 100644 --- a/common/store.cpp +++ b/common/store.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -45,6 +46,11 @@ QString Store::storageLocation() return Sink::storageLocation(); } +QString Store::getTemporaryFilePath() +{ + return Sink::temporaryFileLocation() + "/" + QUuid::createUuid().toString(); +} + static QList getResources(const QList &resourceFilter, const QByteArray &type = QByteArray()) { // Return the global resource (signified by an empty name) for types that don't belong to a specific resource diff --git a/common/store.h b/common/store.h index af8e971..aed3be4 100644 --- a/common/store.h +++ b/common/store.h @@ -43,6 +43,11 @@ namespace Store { QString SINK_EXPORT storageLocation(); +/** + * Returns a unique path for a writable file that can be used to write BLOB properties. + */ +QString SINK_EXPORT getTemporaryFilePath(); + enum Roles { DomainObjectRole = Qt::UserRole + 1, // Must be the same as in ModelResult @@ -51,8 +56,8 @@ enum Roles }; /** - * Asynchronusly load a dataset with tree structure information - */ +* Asynchronusly load a dataset with tree structure information +*/ template QSharedPointer SINK_EXPORT loadModel(Query query); -- cgit v1.2.3