mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Only create the path to no cloud local storage once
This required a small change to the helper function, but this seemed totally worth it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
78d420ac32
commit
05a51f7984
2 changed files with 13 additions and 7 deletions
|
@ -928,7 +928,12 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
|
|||
int git_create_local_repo(const char *filename)
|
||||
{
|
||||
git_repository *repo;
|
||||
int ret = git_repository_init(&repo, filename, false);
|
||||
char *path = strdup(filename);
|
||||
char *branch = strchr(path, '[');
|
||||
if (branch)
|
||||
*branch = '\0';
|
||||
int ret = git_repository_init(&repo, path, false);
|
||||
free(path);
|
||||
if (ret != 0)
|
||||
(void)report_error("Create local repo failed with error code %d", ret);
|
||||
return ret;
|
||||
|
|
|
@ -27,6 +27,8 @@ QMLManager *QMLManager::m_instance = NULL;
|
|||
#define RED_FONT QLatin1Literal("<font color=\"red\">")
|
||||
#define END_FONT QLatin1Literal("</font>")
|
||||
|
||||
#define NOCLOUD_LOCALSTORAGE format_string("%s/cloudstorage/localrepo[master]", system_default_directory())
|
||||
|
||||
static void appendTextToLogStandalone(const char *text)
|
||||
{
|
||||
QMLManager *self = QMLManager::instance();
|
||||
|
@ -172,7 +174,7 @@ void QMLManager::openLocalThenRemote(QString url)
|
|||
|
||||
void QMLManager::mergeLocalRepo()
|
||||
{
|
||||
char *filename = format_string("%s/cloudstorage/localrepo[master]", system_default_directory());
|
||||
char *filename = NOCLOUD_LOCALSTORAGE;
|
||||
parse_file(filename);
|
||||
process_dives(true, false);
|
||||
}
|
||||
|
@ -479,6 +481,7 @@ void QMLManager::revertToNoCloudIfNeeded()
|
|||
setCloudUserName("");
|
||||
setCloudPassword("");
|
||||
setCredentialStatus(INCOMPLETE);
|
||||
set_filename(NOCLOUD_LOCALSTORAGE, true);
|
||||
setStartPageText(RED_FONT + tr("Failed to connect to cloud server, reverting to no cloud status") + END_FONT);
|
||||
}
|
||||
setAccessingCloud(-1);
|
||||
|
@ -868,12 +871,10 @@ void QMLManager::saveChangesLocal()
|
|||
git_storage_update_progress(true, "saving dives locally"); // reset the timers
|
||||
if (credentialStatus() == NOCLOUD) {
|
||||
if (same_string(existing_filename, "")) {
|
||||
QString filename(system_default_directory());
|
||||
filename += "/cloudstorage/localrepo";
|
||||
if (git_create_local_repo(qPrintable(filename)))
|
||||
char *filename = NOCLOUD_LOCALSTORAGE;
|
||||
if (git_create_local_repo(filename))
|
||||
appendTextToLog(get_error_string());
|
||||
filename += "[master]";
|
||||
set_filename(qPrintable(filename), true);
|
||||
set_filename(filename, true);
|
||||
GeneralSettingsObjectWrapper s(this);
|
||||
s.setDefaultFilename(filename);
|
||||
s.setDefaultFileBehavior(LOCAL_DEFAULT_FILE);
|
||||
|
|
Loading…
Reference in a new issue