From db965cf86aa8d4dbeed6f93a2a045874bb711caa Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 6 Jun 2020 09:55:49 -0700 Subject: [PATCH] mobile: add helper to import data from local cloud cache If you pass in the repo name, it isn't treated as cloud storage, but simply as local git storage and imported (i.e., added) to the current dive list. This allows the user to work around failed no-cloud->cloud transitions, merge different accounts, and most importantly deal with situations were conflicts on the server caused us to move a cache out of the way and potentially make dives that were on the mobile device inaccessible to the user. Once a UI is added, this allows the user to recover those dives (realistically this is not really all that potentially 'dangerous' to do, but it's definitely something that would best be done after talking to someone who understands the cloud storage and can guide the user...). Signed-off-by: Dirk Hohndel --- mobile-widgets/qmlmanager.cpp | 12 ++++++++++++ mobile-widgets/qmlmanager.h | 1 + 2 files changed, 13 insertions(+) diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 7ec3df7ba..f338e5ba5 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -2207,6 +2207,18 @@ void QMLManager::setDiveListProcessing(bool value) } +void QMLManager::importCacheRepo(QString repo) +{ + struct dive_table table = empty_dive_table; + struct trip_table trips = empty_trip_table; + struct dive_site_table sites = empty_dive_site_table; + QString repoPath = QString("%1/cloudstorage/%2").arg(system_default_directory()).arg(repo); + appendTextToLog(QString("importing %1").arg(repoPath)); + parse_file(qPrintable(repoPath), &table, &trips, &sites); + add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS); + changesNeedSaving(); +} + QStringList QMLManager::cloudCacheList() const { QDir localCacheDir(QString("%1/cloudstorage/").arg(system_default_directory())); diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 1e932e451..03a5864a1 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -119,6 +119,7 @@ public: Q_INVOKABLE void setFilter(const QString filterText, int mode); Q_INVOKABLE void selectRow(int row); Q_INVOKABLE void selectSwipeRow(int row); + Q_INVOKABLE void importCacheRepo(QString repo); static QMLManager *instance(); Q_INVOKABLE void registerError(QString error);