summaryrefslogtreecommitdiffstats
path: root/save-git.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-12 12:32:12 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-12 13:56:23 -0700
commite21cae2d46db8148dc294c2dff08d9321274f815 (patch)
tree3c96b90a46cc43534bc332aa1157cdb62c8a5ec5 /save-git.c
parent492369b3125b2c1c91f134c360110440b03d33b6 (diff)
downloadsubsurface-e21cae2d46db8148dc294c2dff08d9321274f815.tar.gz
Cloud storage: sync the remote after save
This change once again tests if the remote can be reached. Even with a fairly big data file and a medium speed internet connection the remote sync is fast enough to call it nearly instantaneous. Maybe a couple of seconds. We may need more checks / different heuristics / warnings if the sync didn't happen, etc. But for now this should allow more reasonable testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-git.c')
-rw-r--r--save-git.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/save-git.c b/save-git.c
index 16db95f6c..662ec408f 100644
--- a/save-git.c
+++ b/save-git.c
@@ -1115,7 +1115,7 @@ static int write_git_tree(git_repository *repo, struct dir *tree, git_oid *resul
return ret;
}
-static int do_git_save(git_repository *repo, const char *branch, bool select_only)
+static int do_git_save(git_repository *repo, const char *branch, const char *remote, bool select_only)
{
struct dir tree;
git_oid id;
@@ -1134,16 +1134,24 @@ static int do_git_save(git_repository *repo, const char *branch, bool select_onl
return report_error("git tree write failed");
/* And save the tree! */
- return create_new_commit(repo, branch, &id);
+ if (create_new_commit(repo, branch, &id))
+ return report_error("creating commit failed");
+
+ if (prefs.cloud_background_sync) {
+ /* now sync the tree with the cloud server */
+ if (strstr(remote, "https://cloud.subsurface-divelog.org")) {
+ sync_with_remote(repo, remote, branch);
+ }
+ }
}
-int git_save_dives(struct git_repository *repo, const char *branch, bool select_only)
+int git_save_dives(struct git_repository *repo, const char *branch, const char *remote, bool select_only)
{
int ret;
if (repo == dummy_git_repository)
return report_error("Unable to open git repository '%s'", branch);
- ret = do_git_save(repo, branch, select_only);
+ ret = do_git_save(repo, branch, remote, select_only);
git_repository_free(repo);
free((void *)branch);
return ret;