From 85dfb88f51098158a5fac52ce432a07625374c70 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 22 Jun 2015 06:45:48 -0700 Subject: 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 --- qthelper.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'qthelper.cpp') 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)); } -- cgit v1.2.3-70-g09d2