diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-02-18 16:22:34 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-03-05 18:04:57 +0200 |
commit | bdc470a80e0260011e3dfc4d949df8f9e222f73f (patch) | |
tree | 625c26f2f754a56929d2f8880170c38b8f7d779b /core/imagedownloader.cpp | |
parent | e5dcd9fc161891a4e70364e1dcdf232590eb49c6 (diff) | |
download | subsurface-bdc470a80e0260011e3dfc4d949df8f9e222f73f.tar.gz |
Cleanup: Remove hash field from picture-structure
The hash field in the picture-structure was in principle non-operational.
It was set on loading, but never actually changed. The authoritative
hash comes from the filename->hash map.
Therefore, make this explicit by removing the hash field from the
picture structure.
Instead of filling the picture structure on loading, add the
hash directly to the filename->hash map. This is done in the
register_hash() function, which does not overwrite old entries.
I.e. the local hash has priority over the save-file. This
policy might be refined in the future.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/imagedownloader.cpp')
-rw-r--r-- | core/imagedownloader.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index e486830d2..fe0bf138a 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -9,8 +9,9 @@ #include <QtConcurrent> -static QUrl cloudImageURL(const char *hash) +static QUrl cloudImageURL(const char *filename) { + QString hash = hashString(filename); return QUrl::fromUserInput(QString("https://cloud.subsurface-divelog.org/images/").append(hash)); } @@ -26,7 +27,7 @@ ImageDownloader::~ImageDownloader() void ImageDownloader::load(bool fromHash) { - if (fromHash && loadFromUrl(cloudImageURL(picture->hash))) + if (fromHash && loadFromUrl(cloudImageURL(picture->filename))) return; // If loading from hash failed, try to load from filename @@ -107,12 +108,11 @@ SHashedImage::SHashedImage(struct picture *picture) : QImage() if (isNull()) { // This did not load anything. Let's try to get the image from other sources // Let's try to load it locally via its hash - QString filename = fileFromHash(picture->hash); - if (filename.isNull()) - filename = QString(picture->filename); + QString filename = localFilePath(picture->filename); if (filename.isNull()) { // That didn't produce a local filename. // Try the cloud server + // TODO: This is dead code at the moment. QtConcurrent::run(loadPicture, clone_picture(picture), true); } else { // Load locally from translated file name |