dbhub: Redownload database when checking out current commit

When double clicking the currently checked out commit in the commits
list in the Remote dock only open the local file if it has not been
modified. If it was modified show a warning about the modifications and
redownload the file if the user decides to proceed.

See issue #2349.
This commit is contained in:
Martin Kleusberg
2020-08-12 20:26:50 +02:00
parent c77cb97226
commit 69eec2b602

View File

@@ -242,15 +242,25 @@ void RemoteDock::fetchDatabase(QString url_string, RemoteNetwork::RequestType re
return;
}
// For the user name, take the path, remove the database name and the initial slash
QString username = url.path().remove("/" + url.fileName()).mid(1);
// There is a chance that we've already cloned that database. So check for that first
QString exists = remoteDatabase.localExists(url, remoteModel->currentClientCertificate(), QUrlQuery(url).queryItemValue("branch").toStdString());
if(!exists.isEmpty() && request_type == RemoteNetwork::RequestTypeDatabase)
{
// Check for modifications
bool modified = isLocalDatabaseModified(exists, username, url.fileName(), remoteModel->currentClientCertificate(),
QUrlQuery(url).queryItemValue("commit").toStdString());
// Database has already been cloned! So open the local file instead of fetching the one from the
// server again.
emit openFile(exists);
return;
// server again. If the local file has been modified don't open it but try to download the last known
// commit again.
if(!modified)
{
emit openFile(exists);
return;
}
}
// Check if we already have a clone of this database branch and, if so, figure out its local file name.
@@ -265,9 +275,6 @@ void RemoteDock::fetchDatabase(QString url_string, RemoteNetwork::RequestType re
{
// If there is a local clone of this dtabase and branch, figure out if the local file has been modified
// For the user name, take the path, remove the database name and the initial slash
QString username = url.path().remove("/" + url.fileName()).mid(1);
// Get the last local commit id
std::string last_commit_id = remoteDatabase.localLastCommitId(remoteModel->currentClientCertificate(), url, QUrlQuery(url).queryItemValue("branch").toStdString());