mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-27 22:40:34 -06:00
dbhub: Only show warning about losing unsaved changes when downloading
Make sure to only show a warning that local changes might be lost before actually downloading a database and overriding the local copy. When we just open the local copy, no warning needs to be shown.
This commit is contained in:
@@ -524,6 +524,27 @@ void RemoteDatabase::fetch(const QUrl& url, RequestType type, const QString& cli
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we already have a clone of this database branch. If so, show a warning because there might
|
||||
// be unpushed changes. For this we don't care about the currently checked out commit id because for
|
||||
// any commit local changes could be lost.
|
||||
// TODO Detect local changes and don't warn when no changes were made
|
||||
QUrl url_without_commit_id(url);
|
||||
QUrlQuery url_without_commit_id_query(url_without_commit_id);
|
||||
url_without_commit_id_query.removeQueryItem("commit");
|
||||
url_without_commit_id.setQuery(url_without_commit_id_query);
|
||||
if(!localExists(url_without_commit_id, clientCert, QUrlQuery(url).queryItemValue("branch").toStdString()).isEmpty())
|
||||
{
|
||||
if(QMessageBox::warning(nullptr,
|
||||
QApplication::applicationName(),
|
||||
tr("Fetching this commit might override local changes when you have not pushed them yet.\n"
|
||||
"Are you sure you want to fetch it?"),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel) == QMessageBox::Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Build network request
|
||||
QNetworkRequest request;
|
||||
request.setUrl(url);
|
||||
|
||||
@@ -192,29 +192,6 @@ void RemoteDock::fetchDatabase(QString url_string)
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we already have a clone of this database branch. In so, show a warning because there might
|
||||
// be unpushed changes. For this we don't care about the currently checked out commit id because for
|
||||
// any commit local changes could be lost.
|
||||
// TODO Detect local changes and don't warn when no changes were made
|
||||
QUrl url_without_commit_id(url);
|
||||
QUrlQuery url_without_commit_id_query(url_without_commit_id);
|
||||
url_without_commit_id_query.removeQueryItem("commit");
|
||||
url_without_commit_id.setQuery(url_without_commit_id_query);
|
||||
if(!remoteDatabase.localExists(url_without_commit_id, remoteModel->currentClientCertificate(), QUrlQuery(url).queryItemValue("branch").toStdString()).isEmpty())
|
||||
{
|
||||
|
||||
|
||||
if(QMessageBox::warning(this,
|
||||
QApplication::applicationName(),
|
||||
tr("Fetching this commit might override local changes when you have not pushed them yet.\n"
|
||||
"Are you sure you want to fetch it?"),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel) == QMessageBox::Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Clone the database
|
||||
remoteDatabase.fetch(url.toString(), RemoteDatabase::RequestTypeDatabase, remoteModel->currentClientCertificate());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user