mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-13 12:42:20 +00:00
Key the CloudDB cache by hostname and add a button to clear the cache (#4794)
Using the new go125 server for testing purposes [publish binaries]
This commit is contained in:
@@ -50,10 +50,10 @@ CloudDBChartClient::CloudDBChartClient()
|
|||||||
g_nam = new QNetworkAccessManager(this);
|
g_nam = new QNetworkAccessManager(this);
|
||||||
QDir cacheDir(QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation).at(0));
|
QDir cacheDir(QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation).at(0));
|
||||||
cacheDir.cdUp();
|
cacheDir.cdUp();
|
||||||
g_cacheDir = QString(cacheDir.absolutePath()+"/GoldenCheetahCloudDB");
|
g_cacheDir = QString(cacheDir.absolutePath()+"/GoldenCheetahCloudDB/" + QString(QT_STRINGIFY(GC_CLOUD_DB_APP_NAME)));
|
||||||
QDir newCacheDir(g_cacheDir);
|
QDir newCacheDir(g_cacheDir);
|
||||||
if (!newCacheDir.exists()) {
|
if (!newCacheDir.exists()) {
|
||||||
cacheDir.mkdir("GoldenCheetahCloudDB");
|
newCacheDir.mkpath(g_cacheDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// general handling for sslErrors
|
// general handling for sslErrors
|
||||||
@@ -237,6 +237,15 @@ CloudDBChartClient::getAllChartHeader(QList<CommonAPIHeaderV1>* header) {
|
|||||||
return request_ok;
|
return request_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CloudDBChartClient::clearAllCache() {
|
||||||
|
QDir cacheDir(g_cacheDir);
|
||||||
|
if (cacheDir.exists()) {
|
||||||
|
return cacheDir.removeRecursively();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Trap SSL errors
|
// Trap SSL errors
|
||||||
@@ -449,20 +458,24 @@ CloudDBChartListDialog::CloudDBChartListDialog() : const_stepSize(5)
|
|||||||
showing = new QLabel;
|
showing = new QLabel;
|
||||||
showingTextTemplate = tr("Showing %1 to %2 of %3 charts for %4 / Total uploaded %5");
|
showingTextTemplate = tr("Showing %1 to %2 of %3 charts for %4 / Total uploaded %5");
|
||||||
resetToStart = new QPushButton(tr("First"));
|
resetToStart = new QPushButton(tr("First"));
|
||||||
|
clearCacheButton = new QPushButton(tr("Clear Cache"));
|
||||||
nextSet = new QPushButton(tr("Next %1").arg(QString::number(const_stepSize)));
|
nextSet = new QPushButton(tr("Next %1").arg(QString::number(const_stepSize)));
|
||||||
prevSet = new QPushButton(tr("Prev %1").arg(QString::number(const_stepSize)));
|
prevSet = new QPushButton(tr("Prev %1").arg(QString::number(const_stepSize)));
|
||||||
resetToStart->setEnabled(true);
|
resetToStart->setEnabled(true);
|
||||||
nextSet->setDefault(true);
|
nextSet->setDefault(true);
|
||||||
|
clearCacheButton->setEnabled(true);
|
||||||
nextSet->setEnabled(true);
|
nextSet->setEnabled(true);
|
||||||
prevSet->setEnabled(true);
|
prevSet->setEnabled(true);
|
||||||
|
|
||||||
connect(resetToStart, SIGNAL(clicked()), this, SLOT(resetToStartClicked()));
|
connect(resetToStart, SIGNAL(clicked()), this, SLOT(resetToStartClicked()));
|
||||||
connect(nextSet, SIGNAL(clicked()), this, SLOT(nextSetClicked()));
|
connect(nextSet, SIGNAL(clicked()), this, SLOT(nextSetClicked()));
|
||||||
connect(prevSet, SIGNAL(clicked()), this, SLOT(prevSetClicked()));
|
connect(prevSet, SIGNAL(clicked()), this, SLOT(prevSetClicked()));
|
||||||
|
connect(clearCacheButton, &QPushButton::clicked, this, &CloudDBChartListDialog::clearCacheClicked);
|
||||||
|
|
||||||
showingLayout = new QHBoxLayout;
|
showingLayout = new QHBoxLayout;
|
||||||
showingLayout->addWidget(showing);
|
showingLayout->addWidget(showing);
|
||||||
showingLayout->addStretch();
|
showingLayout->addStretch();
|
||||||
|
showingLayout->addWidget(clearCacheButton);
|
||||||
showingLayout->addWidget(resetToStart);
|
showingLayout->addWidget(resetToStart);
|
||||||
showingLayout->addWidget(prevSet);
|
showingLayout->addWidget(prevSet);
|
||||||
showingLayout->addWidget(nextSet);
|
showingLayout->addWidget(nextSet);
|
||||||
@@ -659,6 +672,7 @@ CloudDBChartListDialog::updateCurrentPresets(int index, int count) {
|
|||||||
prevSet->setEnabled(false);
|
prevSet->setEnabled(false);
|
||||||
closeUserGetButton->setEnabled(false);
|
closeUserGetButton->setEnabled(false);
|
||||||
addAndCloseUserGetButton->setEnabled(false);
|
addAndCloseUserGetButton->setEnabled(false);
|
||||||
|
clearCacheButton->setEnabled(false);
|
||||||
curationStateCombo->setEnabled(false);
|
curationStateCombo->setEnabled(false);
|
||||||
ownChartsOnly->setEnabled(false);
|
ownChartsOnly->setEnabled(false);
|
||||||
textFilterApply->setEnabled(false);
|
textFilterApply->setEnabled(false);
|
||||||
@@ -755,8 +769,10 @@ CloudDBChartListDialog::updateCurrentPresets(int index, int count) {
|
|||||||
resetToStart->setEnabled(true);
|
resetToStart->setEnabled(true);
|
||||||
nextSet->setEnabled(true);
|
nextSet->setEnabled(true);
|
||||||
prevSet->setEnabled(true);
|
prevSet->setEnabled(true);
|
||||||
|
clearCacheButton->setEnabled(true);
|
||||||
closeUserGetButton->setEnabled(true);
|
closeUserGetButton->setEnabled(true);
|
||||||
addAndCloseUserGetButton->setEnabled(true);
|
addAndCloseUserGetButton->setEnabled(true);
|
||||||
|
clearCacheButton->setEnabled(true);
|
||||||
curationStateCombo->setEnabled(true);
|
curationStateCombo->setEnabled(true);
|
||||||
ownChartsOnly->setEnabled(true);
|
ownChartsOnly->setEnabled(true);
|
||||||
textFilterApply->setEnabled(true);
|
textFilterApply->setEnabled(true);
|
||||||
@@ -777,6 +793,23 @@ CloudDBChartListDialog::updateCurrentPresets(int index, int count) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CloudDBChartListDialog::clearCacheClicked() {
|
||||||
|
// clear the physical cache
|
||||||
|
g_client->clearAllCache();
|
||||||
|
|
||||||
|
// force a refresh from Network
|
||||||
|
CloudDBHeader::setChartHeaderStale(true);
|
||||||
|
|
||||||
|
// reset UI
|
||||||
|
g_currentIndex = 0;
|
||||||
|
if (CloudDBHeader::isStaleChartHeader()) {
|
||||||
|
if (!refreshStaleChartHeader()) return;
|
||||||
|
CloudDBHeader::setChartHeaderStale(false);
|
||||||
|
}
|
||||||
|
applyAllFilters();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CloudDBChartListDialog::setVisibleButtonsForRole() {
|
CloudDBChartListDialog::setVisibleButtonsForRole() {
|
||||||
if (g_role == CloudDBCommon::UserEdit) {
|
if (g_role == CloudDBCommon::UserEdit) {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public:
|
|||||||
bool curateChartByID(qint64 id, bool newStatus);
|
bool curateChartByID(qint64 id, bool newStatus);
|
||||||
void incrementDownloadCounterByID(qint64 id);
|
void incrementDownloadCounterByID(qint64 id);
|
||||||
bool getAllChartHeader(QList<CommonAPIHeaderV1>* header);
|
bool getAllChartHeader(QList<CommonAPIHeaderV1>* header);
|
||||||
|
bool clearAllCache();
|
||||||
|
|
||||||
bool sslLibMissing() { return noSSLlib; }
|
bool sslLibMissing() { return noSSLlib; }
|
||||||
|
|
||||||
@@ -133,6 +134,7 @@ private slots:
|
|||||||
void resetToStartClicked();
|
void resetToStartClicked();
|
||||||
void nextSetClicked();
|
void nextSetClicked();
|
||||||
void prevSetClicked();
|
void prevSetClicked();
|
||||||
|
void clearCacheClicked();
|
||||||
void ownChartsToggled(bool);
|
void ownChartsToggled(bool);
|
||||||
void toggleTextFilterApply();
|
void toggleTextFilterApply();
|
||||||
void curationStateFilterChanged(int);
|
void curationStateFilterChanged(int);
|
||||||
@@ -172,6 +174,7 @@ private:
|
|||||||
QPushButton *resetToStart;
|
QPushButton *resetToStart;
|
||||||
QPushButton *nextSet;
|
QPushButton *nextSet;
|
||||||
QPushButton *prevSet;
|
QPushButton *prevSet;
|
||||||
|
QPushButton *clearCacheButton;
|
||||||
QCheckBox *ownChartsOnly;
|
QCheckBox *ownChartsOnly;
|
||||||
QComboBox *curationStateCombo;
|
QComboBox *curationStateCombo;
|
||||||
QComboBox *langCombo;
|
QComboBox *langCombo;
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ CloudDBUserMetricClient::CloudDBUserMetricClient()
|
|||||||
g_nam = new QNetworkAccessManager(this);
|
g_nam = new QNetworkAccessManager(this);
|
||||||
QDir cacheDir(QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation).at(0));
|
QDir cacheDir(QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation).at(0));
|
||||||
cacheDir.cdUp();
|
cacheDir.cdUp();
|
||||||
g_cacheDir = QString(cacheDir.absolutePath()+"/GoldenCheetahCloudDB");
|
g_cacheDir = QString(cacheDir.absolutePath()+"/GoldenCheetahCloudDB/" + QString(QT_STRINGIFY(GC_CLOUD_DB_APP_NAME)));
|
||||||
QDir newCacheDir(g_cacheDir);
|
QDir newCacheDir(g_cacheDir);
|
||||||
if (!newCacheDir.exists()) {
|
if (!newCacheDir.exists()) {
|
||||||
cacheDir.mkdir("GoldenCheetahCloudDB");
|
newCacheDir.mkpath(g_cacheDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// general handling for sslErrors
|
// general handling for sslErrors
|
||||||
|
|||||||
Reference in New Issue
Block a user