working bucket deletions
This commit is contained in:
parent
bf28495b1f
commit
906cff2e57
@ -52,8 +52,23 @@ bool BoltDB::addBucket(QStringList bucketPath, QByteArray bucketName, QString& e
|
|||||||
|
|
||||||
bool BoltDB::deleteBucket(QStringList bucketPath, QByteArray bucketName, QString& errorOut)
|
bool BoltDB::deleteBucket(QStringList bucketPath, QByteArray bucketName, QString& errorOut)
|
||||||
{
|
{
|
||||||
errorOut = "Not implemented";
|
GoSliceManagedWrapper browse(&bucketPath);
|
||||||
return false; // not implemented
|
GoString bucketNameGS = Interop::toGoString_WeakRef(&bucketName);
|
||||||
|
auto resp = ::Bolt_DeleteBucket(this->gmsDbRef, browse.slice, bucketNameGS);
|
||||||
|
|
||||||
|
if (resp.r0 == ERROR_AND_STOP_CALLING) {
|
||||||
|
errorOut = QString::fromUtf8(resp.r1, resp.r2);
|
||||||
|
free(resp.r1);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} else if (resp.r0 == FINISHED_OK) {
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// ?? unreachable
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::listBucketsAtRoot(QString& errorOut, NameReciever cb)
|
bool BoltDB::listBucketsAtRoot(QString& errorOut, NameReciever cb)
|
||||||
|
@ -366,10 +366,25 @@ void MainWindow::on_actionDelete_bucket_triggered()
|
|||||||
auto *bdb = GET_BDB(top);
|
auto *bdb = GET_BDB(top);
|
||||||
|
|
||||||
// Prompt for confirmation
|
// Prompt for confirmation
|
||||||
|
QString bucketToDelete = itm->text(0);
|
||||||
if (QMessageBox::question(this, tr("Delete bucket"), tr("Are you sure you want to remove the bucket '%s'?").arg(itm->text(0)), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes) {
|
if (QMessageBox::question(this, tr("Delete bucket"), tr("Are you sure you want to remove the bucket '%1'?").arg(bucketToDelete), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// One level down
|
||||||
|
|
||||||
|
browse.pop_back();
|
||||||
|
|
||||||
|
QString err;
|
||||||
|
if (! bdb->deleteBucket(browse, bucketToDelete.toUtf8(), err)) {
|
||||||
|
QMessageBox qmb;
|
||||||
|
qmb.setText(tr("Error removing bucket: %1").arg(err));
|
||||||
|
qmb.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh bucket list
|
||||||
|
refreshBucketTree(itm->parent()); // sub-tree only
|
||||||
|
ui->bucketTree->expandItem(itm->parent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user