aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/load-git.c62
-rw-r--r--core/qthelper.cpp28
-rw-r--r--core/qthelper.h2
-rw-r--r--core/save-git.c16
4 files changed, 1 insertions, 107 deletions
diff --git a/core/load-git.c b/core/load-git.c
index 731045087..3de094356 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -29,14 +29,6 @@
const char *saved_git_id = NULL;
-struct picture_entry_list {
- void *data;
- int len;
- const char *hash;
- struct picture_entry_list *next;
-};
-struct picture_entry_list *pel = NULL;
-
struct keyword_action {
const char *keyword;
void (*fn)(char *, struct membuffer *, void *);
@@ -46,23 +38,6 @@ struct keyword_action {
extern degrees_t parse_degrees(char *buf, char **end);
git_blob *git_tree_entry_blob(git_repository *repo, const git_tree_entry *entry);
-static void save_picture_from_git(struct picture *picture)
-{
- struct picture_entry_list *pic_entry = pel;
-
- while (pic_entry) {
- char *hash = hashstring(picture->filename);
- if (same_string(pic_entry->hash, hash)) {
- savePictureLocal(picture, hash, pic_entry->data, pic_entry->len);
- free(hash);
- return;
- }
- free(hash);
- pic_entry = pic_entry->next;
- }
- fprintf(stderr, "didn't find picture entry for %s\n", picture->filename);
-}
-
static char *get_utf8(struct membuffer *b)
{
int len = b->len;
@@ -1217,18 +1192,6 @@ static void finish_active_dive(void)
struct dive *dive = active_dive;
if (dive) {
- /* check if we need to save pictures */
- FOR_EACH_PICTURE(dive) {
- if (!picture_exists(picture))
- save_picture_from_git(picture);
- }
- /* free any memory we allocated to track pictures */
- while (pel) {
- free(pel->data);
- void *lastone = pel;
- pel = pel->next;
- free(lastone);
- }
active_dive = NULL;
record_dive(dive);
}
@@ -1590,26 +1553,6 @@ static int parse_settings_entry(git_repository *repo, const git_tree_entry *entr
return 0;
}
-static int parse_picture_file(git_repository *repo, const git_tree_entry *entry, const char *name)
-{
- /* remember the picture data so we can handle it when all dive data has been loaded
- * the name of the git file is PIC-<hash> */
- git_blob *blob = git_tree_entry_blob(repo, entry);
- if (blob) {
- const void*rawdata = git_blob_rawcontent(blob);
- int len = git_blob_rawsize(blob);
- struct picture_entry_list *new_pel = malloc(sizeof(struct picture_entry_list));
- new_pel->next = pel;
- pel = new_pel;
- pel->data = malloc(len);
- memcpy(pel->data, rawdata, len);
- pel->len = len;
- pel->hash = strdup(name + 4);
- git_blob_free(blob);
- }
- return 0;
-}
-
static int parse_picture_entry(git_repository *repo, const git_tree_entry *entry, const char *name)
{
git_blob *blob;
@@ -1651,7 +1594,6 @@ static int walk_tree_file(const char *root, const git_tree_entry *entry, git_rep
if (verbose > 1)
fprintf(stderr, "git load handling file %s\n", name);
switch (*name) {
- /* Picture file? They are saved as time offsets in the dive */
case '-': case '+':
if (dive)
return parse_picture_entry(repo, entry, name);
@@ -1672,10 +1614,6 @@ static int walk_tree_file(const char *root, const git_tree_entry *entry, git_rep
if (!strcmp(name, "00-Subsurface"))
return parse_settings_entry(repo, entry);
break;
- case 'P':
- if (dive && !strncmp(name, "PIC-", 4))
- return parse_picture_file(repo, entry, name);
- break;
}
report_error("Unknown file %s%s (%p %p)", root, name, dive, trip);
return GIT_WALK_SKIP;
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index b44ef7d6f..11d74a14e 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1293,15 +1293,6 @@ extern "C" const char *local_file_path(struct picture *picture)
return copy_qstring(localFilePath(picture->filename));
}
-extern "C" bool picture_exists(struct picture *picture)
-{
- QString localPath = localFilePath(picture->filename);
- if (localPath.isEmpty())
- return false;
- QByteArray hash = hashFile(localPath);
- return !hash.isEmpty() && getHash(QString(picture->filename)) == hash;
-}
-
const QString picturedir()
{
return QString(system_default_directory()).append("/picturedata/");
@@ -1312,25 +1303,6 @@ extern "C" char *picturedir_string()
return copy_qstring(picturedir());
}
-/* when we get a picture from git storage (local or remote) and can't find the picture
- * based on its hash, we create a local copy with the hash as filename and the appropriate
- * suffix */
-extern "C" void savePictureLocal(struct picture *picture, const char *hash, const char *data, int len)
-{
- QString dirname = picturedir();
- QDir localPictureDir(dirname);
- localPictureDir.mkpath(dirname);
- QString suffix(picture->filename);
- suffix.replace(QRegularExpression(".*\\."), "");
- QString filename(dirname + hash + "." + suffix);
- QSaveFile out(filename);
- if (out.open(QIODevice::WriteOnly)) {
- out.write(data, len);
- out.commit();
- add_hash(filename, QByteArray::fromHex(hash));
- }
-}
-
QString get_gas_string(struct gasmix gas)
{
uint o2 = (get_o2(&gas) + 5) / 10, he = (get_he(&gas) + 5) / 10;
diff --git a/core/qthelper.h b/core/qthelper.h
index 41a76ad3b..e6a5d7fd6 100644
--- a/core/qthelper.h
+++ b/core/qthelper.h
@@ -69,10 +69,8 @@ char *get_file_name(const char *fileName);
void copy_image_and_overwrite(const char *cfileName, const char *path, const char *cnewName);
char *hashstring(const char *filename);
void register_hash(const char *filename, const char *hash);
-bool picture_exists(struct picture *picture);
char *move_away(const char *path);
const char *local_file_path(struct picture *picture);
-void savePictureLocal(struct picture *picture, const char *hash, const char *data, int len);
void cache_picture(struct picture *picture);
char *cloud_url();
char *hashfile_name_string();
diff --git a/core/save-git.c b/core/save-git.c
index 23d26961f..9ed315028 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -611,7 +611,6 @@ static int save_one_picture(git_repository *repo, struct dir *dir, struct pictur
char sign = '+';
char *hash;
unsigned h;
- int error;
show_utf8(&buf, "filename ", pic->filename, "\n");
show_gps(&buf, pic->latitude, pic->longitude);
@@ -628,21 +627,8 @@ static int save_one_picture(git_repository *repo, struct dir *dir, struct pictur
/* Use full hh:mm:ss format to make it all sort nicely */
h = offset / 3600;
offset -= h *3600;
- error = blob_insert(repo, dir, &buf, "%c%02u=%02u=%02u",
+ return blob_insert(repo, dir, &buf, "%c%02u=%02u=%02u",
sign, h, FRACTION(offset, 60));
-#if 0
- /* storing pictures into git was a mistake. This makes for HUGE git repositories */
- if (!error) {
- /* next store the actual picture; we prefix all picture names
- * with "PIC-" to make things easier on the parsing side */
- struct membuffer namebuf = { 0 };
- 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);
- }
-#endif
- return error;
}
static int save_pictures(git_repository *repo, struct dir *dir, struct dive *dive)