mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
492369b312
commit
e21cae2d46
5 changed files with 41 additions and 22 deletions
16
save-git.c
16
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue