mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-24 22:48:23 -05:00
dbhub: Do not allow pushing in-memory databases
Because there is no local file on the disk to upload in-memory database cannot be uploaded to the remote server. This commit makes sure the button to upload databases is disabled for in-memory databases. It also fixes a problem where some information on a previously opened database would remain visible when opening an in-memory database.
This commit is contained in:
@@ -568,6 +568,7 @@ void MainWindow::fileNewInMemoryDatabase()
|
||||
statusEncodingLabel->setText(db.getPragma("encoding"));
|
||||
statusEncryptionLabel->setVisible(false);
|
||||
statusReadOnlyLabel->setVisible(false);
|
||||
remoteDock->fileOpened(":memory:");
|
||||
populateTable();
|
||||
if(ui->tabSqlAreas->count() == 0)
|
||||
openSqlTab(true);
|
||||
|
||||
+17
-8
@@ -138,7 +138,7 @@ void RemoteDock::fetchDatabase(const QModelIndex& idx)
|
||||
|
||||
void RemoteDock::enableButtons()
|
||||
{
|
||||
bool db_opened = mainWindow->getDb().isOpen();
|
||||
bool db_opened = mainWindow->getDb().isOpen() && mainWindow->getDb().currentFile() != ":memory:";
|
||||
bool logged_in = !remoteModel->currentClientCertificate().isEmpty();
|
||||
|
||||
ui->buttonPushDatabase->setEnabled(db_opened && logged_in);
|
||||
@@ -250,20 +250,29 @@ void RemoteDock::openLocalFile(const QModelIndex& idx)
|
||||
|
||||
void RemoteDock::fileOpened(const QString& filename)
|
||||
{
|
||||
// Check if it is a tracked remote database file and retrieve the information we have on it
|
||||
// Clear data first
|
||||
currently_opened_file_info.clear();
|
||||
remoteCommitsModel->clear();
|
||||
ui->labelDatabaseUser->setText(QString());
|
||||
ui->labelDatabaseFile->setText(QString());
|
||||
ui->labelDatabaseBranch->setText(QString());
|
||||
|
||||
// Do nothing if the file name is empty (indicating a closed database) or this is an in-memory database
|
||||
if(filename.isEmpty() || filename == ":memory:")
|
||||
return;
|
||||
|
||||
// Check if it is a tracked remote database file and retrieve the information we have on it
|
||||
if(filename.startsWith(Settings::getValue("remote", "clonedirectory").toString()))
|
||||
currently_opened_file_info = remoteDatabase.localGetLocalFileInfo(filename);
|
||||
|
||||
// Copy information to view
|
||||
remoteCommitsModel->clear();
|
||||
ui->labelDatabaseUser->setText(currently_opened_file_info.user_name());
|
||||
ui->labelDatabaseFile->setText(QString::fromStdString(currently_opened_file_info.name));
|
||||
ui->labelDatabaseBranch->setText(QString::fromStdString(currently_opened_file_info.branch));
|
||||
|
||||
// Is this actually a clone of a remote database?
|
||||
if(!currently_opened_file_info.file.empty())
|
||||
{
|
||||
// Copy information to view
|
||||
ui->labelDatabaseUser->setText(currently_opened_file_info.user_name());
|
||||
ui->labelDatabaseFile->setText(QString::fromStdString(currently_opened_file_info.name));
|
||||
ui->labelDatabaseBranch->setText(QString::fromStdString(currently_opened_file_info.branch));
|
||||
|
||||
// Make sure the current identity matches the identity used to clone this file in the first place.
|
||||
// A mismatch is possible when the local database file has been opened using a recent files menu item or some similar technique.
|
||||
if(QString::fromStdString(currently_opened_file_info.identity) != QFileInfo(remoteModel->currentClientCertificate()).fileName())
|
||||
|
||||
Reference in New Issue
Block a user