Correctly create cloud account from mobile

The creation of a cloud account from mobile was broken. This fixes
it. Basically, we need to go online for a moment, and setup a correct
local and remote repo for the cloud storage.

Tested for the following scenarios: 1) inital account creation
including PIN handling from mobile, from a clean install .
2) open an already validated cloud account from a clean install.
3) open no-cloud style local account.
4) Switch between 2 already validated could accounts.
5) Try to create a cloud account without data connection.

Notice that scenario 4) does not work perfectly. A restart of
the app is needed to see the new logbook. So that is to be fixed.

Scenario 5) seems a non realistic corner case. This does not work
in a gracefull way. The user needs to remove the app, install it
again, and retry with data connection.

Further notice this is backgroud/core processing only. So no QML UI
changes as proposed (for example) bij Davide.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
Jan Mulder 2017-07-29 09:39:49 +02:00 committed by Dirk Hohndel
parent 61a35d0bd7
commit e76f527fe5

View file

@ -736,7 +736,9 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
if (verbose > 1)
fprintf(stderr, "git storage: returned from git_clone() with error %d\n", error);
if (error) {
char *msg = giterr_last()->message;
char *msg = "";
if (giterr_last())
msg = giterr_last()->message;
int len = sizeof("reference 'refs/remotes/origin/' not found") + strlen(branch);
char *pattern = malloc(len);
snprintf(pattern, len, "reference 'refs/remotes/origin/%s' not found", branch);
@ -784,12 +786,23 @@ static struct git_repository *get_remote_repo(const char *localdir, const char *
return NULL;
}
return update_local_repo(localdir, remote, branch, rt);
} else {
/* we have no local cache yet */
if (is_subsurface_cloud) {
/* and take us temporarly online to create a local and
* remote cloud repo.
*/
git_repository *ret;
bool glo = prefs.git_local_only;
prefs.git_local_only = false;
ret = create_local_repo(localdir, remote, branch, rt);
prefs.git_local_only = glo;
return ret;
}
}
if (!prefs.git_local_only)
return create_local_repo(localdir, remote, branch, rt);
else
return 0;
/* all normal cases are handled above */
return 0;
}
/*