diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-06-22 06:45:48 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-22 06:45:48 -0700 |
commit | 85dfb88f51098158a5fac52ce432a07625374c70 (patch) | |
tree | 6bc03b021da9e4bb6b9f51ff588219bf484172e0 | |
parent | a4168ed5917457a041303a05e4644e8a0fa4294a (diff) | |
download | subsurface-85dfb88f51098158a5fac52ce432a07625374c70.tar.gz |
Cloud storage: correctly store pictures even if they weren't shown before
We could end up in a situation where the hash for a picture hadn't been
recorded yet and then the lookup to make sure that we find the correct
file actually got us nothing.
Now we make sure that the picture is in the hash table before looking up
the file location and before creating the name of the blob that we store
in git.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qthelper.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/qthelper.cpp b/qthelper.cpp index 09d383bc8..1d215c62b 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -884,7 +884,15 @@ void learnImages(const QDir dir, int max_recursions, bool recursed) extern "C" const char *local_file_path(struct picture *picture) { + QString hashString = picture->hash; + if (hashString.isEmpty()) { + QByteArray hash = hashFile(picture->filename); + free(picture->hash); + picture->hash = strdup(hash.toHex().data()); + } QString localFileName = fileFromHash(picture->hash); + if (localFileName.isEmpty()) + localFileName = picture->filename; return strdup(qPrintable(localFileName)); } |