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>
This commit is contained in:
Dirk Hohndel 2015-06-22 06:45:48 -07:00
parent a4168ed591
commit 85dfb88f51

View file

@ -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));
}