diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2021-04-10 17:40:30 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-04-19 12:51:01 -0700 |
commit | c5eb806adb345e24b13ac4bf106cceb1dc9d3431 (patch) | |
tree | a071c9dede0640e23dd8032e6b1d0863d85b983e /core | |
parent | da6395a4a8b68978caf47f98b48a82fabbe1dd20 (diff) | |
download | subsurface-c5eb806adb345e24b13ac4bf106cceb1dc9d3431.tar.gz |
cloudstorage: some cleanup of cloud url handling
We know the preference is never empty, so stop testing for this. But
don't maintain two different preferences with basically the same
content. Instead add the '/git' suffix where needed and keep this all in
one place.
Simplify the extraction of the branch name from the cloud URL.
Also a typo fix and a new comment.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/checkcloudconnection.cpp | 1 | ||||
-rw-r--r-- | core/file.c | 10 | ||||
-rw-r--r-- | core/git-access.c | 2 | ||||
-rw-r--r-- | core/pref.c | 1 | ||||
-rw-r--r-- | core/pref.h | 1 | ||||
-rw-r--r-- | core/qthelper.cpp | 4 | ||||
-rw-r--r-- | core/settings/qPrefCloudStorage.cpp | 2 | ||||
-rw-r--r-- | core/settings/qPrefCloudStorage.h | 2 |
8 files changed, 7 insertions, 16 deletions
diff --git a/core/checkcloudconnection.cpp b/core/checkcloudconnection.cpp index 98b87aef3..b9a7d3b0e 100644 --- a/core/checkcloudconnection.cpp +++ b/core/checkcloudconnection.cpp @@ -19,6 +19,7 @@ CheckCloudConnection::CheckCloudConnection(QObject *parent) : } +// our own madeup API to make sure we are talking to a Subsurface cloud server #define TEAPOT "/make-latte?number-of-shots=3" #define HTTP_I_AM_A_TEAPOT 418 #define MILK "Linus does not like non-fat milk" diff --git a/core/file.c b/core/file.c index d1cbc3c62..e53d39f4d 100644 --- a/core/file.c +++ b/core/file.c @@ -284,9 +284,7 @@ int check_git_sha(const char *filename, struct git_repository **git_p, const cha *git_p = git; if (branch_p) *branch_p = branch; - if (prefs.cloud_git_url && - strstr(filename, prefs.cloud_git_url) - && git == dummy_git_repository) { + if (strstr(filename, prefs.cloud_base_url) && git == dummy_git_repository) { /* opening the cloud storage repository failed for some reason, * so we don't know if there is additional data in the remote */ free(current_sha); @@ -317,13 +315,11 @@ int parse_file(const char *filename, struct dive_table *table, struct trip_table int ret; git = is_git_repository(filename, &branch, NULL, false); - if (prefs.cloud_git_url && - strstr(filename, prefs.cloud_git_url) - && git == dummy_git_repository) { + if (strstr(filename, prefs.cloud_base_url) && git == dummy_git_repository) /* opening the cloud storage repository failed for some reason * give up here and don't send errors about git repositories */ return -1; - } + if (git) return git_load_dives(git, branch, table, trips, sites, devices, filter_presets); diff --git a/core/git-access.c b/core/git-access.c index 891ecf1e2..0936fa399 100644 --- a/core/git-access.c +++ b/core/git-access.c @@ -1023,7 +1023,7 @@ static struct git_repository *is_remote_git_repository(char *remote, const char /* remember if the current git storage we are working on is our cloud storage * this is used to create more user friendly error message and warnings */ - is_subsurface_cloud = strstr(remote, prefs.cloud_git_url) != NULL; + is_subsurface_cloud = strstr(remote, prefs.cloud_base_url) != NULL; return get_remote_repo(localdir, remote, branch); } diff --git a/core/pref.c b/core/pref.c index bc1f7f3ea..61619c0d1 100644 --- a/core/pref.c +++ b/core/pref.c @@ -103,7 +103,6 @@ void copy_prefs(struct preferences *src, struct preferences *dest) dest->default_filename = copy_string(src->default_filename); dest->default_cylinder = copy_string(src->default_cylinder); dest->cloud_base_url = copy_string(src->cloud_base_url); - dest->cloud_git_url = copy_string(src->cloud_git_url); dest->proxy_host = copy_string(src->proxy_host); dest->proxy_user = copy_string(src->proxy_user); dest->proxy_pass = copy_string(src->proxy_pass); diff --git a/core/pref.h b/core/pref.h index 410280a10..97590c4dc 100644 --- a/core/pref.h +++ b/core/pref.h @@ -82,7 +82,6 @@ struct preferences { // ********** CloudStorage ********** bool cloud_auto_sync; const char *cloud_base_url; - const char *cloud_git_url; const char *cloud_storage_email; const char *cloud_storage_email_encoded; const char *cloud_storage_password; diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 702ee965d..6678cc87f 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -1442,9 +1442,9 @@ int getCloudURL(QString &filename) free((void *)prefs.cloud_storage_email_encoded); prefs.cloud_storage_email_encoded = copy_qstring(email); } - filename = QString(QString(prefs.cloud_git_url) + "/%1[%1]").arg(email); + filename = QString(QString(prefs.cloud_base_url) + "git/%1[%1]").arg(email); if (verbose) - qDebug() << "cloud URL set as" << filename; + qDebug() << "returning cloud URL" << filename; return 0; } diff --git a/core/settings/qPrefCloudStorage.cpp b/core/settings/qPrefCloudStorage.cpp index 24b73394b..6caf619dd 100644 --- a/core/settings/qPrefCloudStorage.cpp +++ b/core/settings/qPrefCloudStorage.cpp @@ -31,7 +31,6 @@ void qPrefCloudStorage::set_cloud_base_url(const QString &value) // only free and set if not default if (prefs.cloud_base_url != default_prefs.cloud_base_url) { qPrefPrivate::copy_txt(&prefs.cloud_base_url, value); - qPrefPrivate::copy_txt(&prefs.cloud_git_url, value + "/git"); } disk_cloud_base_url(true); @@ -44,7 +43,6 @@ void qPrefCloudStorage::disk_cloud_base_url(bool doSync) qPrefPrivate::propSetValue(keyFromGroupAndName(group, "cloud_base_url"), prefs.cloud_base_url, default_prefs.cloud_base_url); } else { prefs.cloud_base_url = copy_qstring(qPrefPrivate::propValue(keyFromGroupAndName(group, "cloud_base_url"), default_prefs.cloud_base_url).toString()); - qPrefPrivate::copy_txt(&prefs.cloud_git_url, QString(prefs.cloud_base_url) + "/git"); } } diff --git a/core/settings/qPrefCloudStorage.h b/core/settings/qPrefCloudStorage.h index b0d24227a..d30f26ae0 100644 --- a/core/settings/qPrefCloudStorage.h +++ b/core/settings/qPrefCloudStorage.h @@ -9,7 +9,6 @@ class qPrefCloudStorage : public QObject { Q_OBJECT Q_PROPERTY(bool cloud_auto_sync READ cloud_auto_sync WRITE set_cloud_auto_sync NOTIFY cloud_auto_syncChanged) Q_PROPERTY(QString cloud_base_url READ cloud_base_url WRITE set_cloud_base_url NOTIFY cloud_base_urlChanged) - Q_PROPERTY(QString cloud_git_url READ cloud_git_url) Q_PROPERTY(QString cloud_storage_email READ cloud_storage_email WRITE set_cloud_storage_email NOTIFY cloud_storage_emailChanged) Q_PROPERTY(QString cloud_storage_email_encoded READ cloud_storage_email_encoded WRITE set_cloud_storage_email_encoded NOTIFY cloud_storage_email_encodedChanged) Q_PROPERTY(QString cloud_storage_password READ cloud_storage_password WRITE set_cloud_storage_password NOTIFY cloud_storage_passwordChanged) @@ -43,7 +42,6 @@ public: static bool cloud_auto_sync() { return prefs.cloud_auto_sync; } static QString cloud_base_url() { return prefs.cloud_base_url; } - static QString cloud_git_url() { return prefs.cloud_git_url; } static QString cloud_storage_email() { return prefs.cloud_storage_email; } static QString cloud_storage_email_encoded() { return prefs.cloud_storage_email_encoded; } static QString cloud_storage_password() { return prefs.cloud_storage_password; } |