working bucket deletions

This commit is contained in:
mappu 2017-05-21 17:14:20 +12:00
parent bf28495b1f
commit 906cff2e57
2 changed files with 34 additions and 4 deletions

View File

@ -52,8 +52,23 @@ bool BoltDB::addBucket(QStringList bucketPath, QByteArray bucketName, QString& e
bool BoltDB::deleteBucket(QStringList bucketPath, QByteArray bucketName, QString& errorOut)
{
errorOut = "Not implemented";
return false; // not implemented
GoSliceManagedWrapper browse(&bucketPath);
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)

View File

@ -366,10 +366,25 @@ void MainWindow::on_actionDelete_bucket_triggered()
auto *bdb = GET_BDB(top);
// Prompt for confirmation
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) {
QString bucketToDelete = itm->text(0);
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;
}
// 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());
}