From c9d48c9a72eec39b614d1d59e3c9fdd66e5a3ab0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 21 Jun 2015 10:29:02 -0700 Subject: Add helper function to return local filename of picture as C string This way we can actually find the picture that we are showing. Signed-off-by: Dirk Hohndel --- qthelper.cpp | 6 ++++++ qthelperfromc.h | 1 + save-git.c | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/qthelper.cpp b/qthelper.cpp index aab06d8b1..3f904d6f1 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -881,6 +881,12 @@ void learnImages(const QDir dir, int max_recursions, bool recursed) QtConcurrent::blockingMap(files, hashFile); } +extern "C" const char *local_file_path(struct picture *picture) +{ + QString localFileName = fileFromHash(picture->hash); + return strdup(qPrintable(localFileName)); +} + extern "C" void picture_load_exif_data(struct picture *p) { EXIFInfo exif; diff --git a/qthelperfromc.h b/qthelperfromc.h index e83cb9782..6e8d92b9f 100644 --- a/qthelperfromc.h +++ b/qthelperfromc.h @@ -9,5 +9,6 @@ void subsurface_mkdir(const char *dir); char *get_file_name(const char *fileName); void copy_image_and_overwrite(const char *cfileName, const char *cnewName); char *hashstring(char *filename); +const char *local_file_path(struct picture *picture); #endif // QTHELPERFROMC_H diff --git a/save-git.c b/save-git.c index b7e519463..1914a07ee 100644 --- a/save-git.c +++ b/save-git.c @@ -628,8 +628,10 @@ static int save_one_picture(git_repository *repo, struct dir *dir, struct pictur /* next store the actual picture; we prefix all picture names * with "PIC-" to make things easier on the parsing side */ struct membuffer namebuf = { 0 }; - put_format(&namebuf, "PIC-%s", hashstring(pic->filename)); - error = blob_insert_fromdisk(repo, dir, pic->filename, mb_cstring(&namebuf)); + const char *localfn = local_file_path(pic); + put_format(&namebuf, "PIC-%s", pic->hash); + error = blob_insert_fromdisk(repo, dir, localfn, mb_cstring(&namebuf)); + free((void *)localfn); } return error; } -- cgit v1.2.3-70-g09d2