mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Create picture cache directory if needed
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e0490f3055
commit
002cfa0663
1 changed files with 5 additions and 1 deletions
|
@ -65,7 +65,11 @@ void ImageDownloader::saveImage(QNetworkReply *reply)
|
||||||
QByteArray imageData = reply->readAll();
|
QByteArray imageData = reply->readAll();
|
||||||
QCryptographicHash hash(QCryptographicHash::Sha1);
|
QCryptographicHash hash(QCryptographicHash::Sha1);
|
||||||
hash.addData(imageData);
|
hash.addData(imageData);
|
||||||
QFile imageFile(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first().append("/").append(hash.result().toHex()));
|
QString path = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first();
|
||||||
|
QDir dir(path);
|
||||||
|
if (!dir.exists())
|
||||||
|
dir.mkpath(path);
|
||||||
|
QFile imageFile(path.append("/").append(hash.result().toHex()));
|
||||||
if (imageFile.open(QIODevice::WriteOnly)) {
|
if (imageFile.open(QIODevice::WriteOnly)) {
|
||||||
QDataStream stream(&imageFile);
|
QDataStream stream(&imageFile);
|
||||||
stream.writeRawData(imageData.data(), imageData.length());
|
stream.writeRawData(imageData.data(), imageData.length());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue