mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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:
parent
a4168ed591
commit
85dfb88f51
1 changed files with 8 additions and 0 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue