Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Apr 17, 2024
1 parent a90ea04 commit 1e47fc8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions db/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (d *BlobSvcDB) GetLatestFinalizingBundle() (*Bundle, error) {
func (d *BlobSvcDB) CreateBundle(b *Bundle) error {
return d.db.Transaction(func(dbTx *gorm.DB) error {
err := dbTx.Create(b).Error
if err != nil && MysqlErrCode(err) != ErrDuplicateEntryCode {
if err != nil && MysqlErrCode(err) == ErrDuplicateEntryCode {
return nil
}
return err
Expand All @@ -138,12 +138,12 @@ func (d *BlobSvcDB) UpdateBundleStatus(bundleName string, status InnerBundleStat
func (d *BlobSvcDB) SaveBlockAndBlob(block *Block, blobs []*Blob) error {
return d.db.Transaction(func(dbTx *gorm.DB) error {
err := dbTx.Save(block).Error
if err != nil && MysqlErrCode(err) != ErrDuplicateEntryCode {
if err != nil && MysqlErrCode(err) == ErrDuplicateEntryCode {
return err
}
if len(blobs) != 0 {
err = dbTx.Save(blobs).Error
if err != nil && MysqlErrCode(err) != ErrDuplicateEntryCode {
if err != nil && MysqlErrCode(err) == ErrDuplicateEntryCode {
return err
}
}
Expand Down
19 changes: 13 additions & 6 deletions scripts/set_up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,29 @@ function prepare() {
}

function create_bucket() {

prepare

./gnfd-cmd -c ./config.toml --home ./ sp ls
sleep 5
./gnfd-cmd -c ./config.toml --home ./ --passwordfile password.txt bucket create gnfd://${BUCKET_NAME}
./gnfd-cmd -c ./config.toml --home ./ bucket head gnfd://${BUCKET_NAME}
echo "bucket created"
}


function grant() {
prepare

./gnfd-cmd -c ./config.toml --home ./ --passwordfile password.txt policy put --grantee ${GRANTEE_BUNDLE_ACCOUNT} --actions createObj grn:b::"$BUCKET_NAME"
sleep 5
./gnfd-cmd -c ./config.toml --home ./ --passwordfile password.txt fee grant --grantee ${GRANTEE_BUNDLE_ACCOUNT} --allowance ${ALLOWANCE}
echo "granted permission"
}

function all() {
prepare
./gnfd-cmd -c ./config.toml --home ./ --passwordfile password.txt bucket create gnfd://${BUCKET_NAME}
sleep 5
./gnfd-cmd -c ./config.toml --home ./ --passwordfile password.txt policy put --grantee ${GRANTEE_BUNDLE_ACCOUNT} --actions createObj grn:b::"$BUCKET_NAME"
sleep 5
./gnfd-cmd -c ./config.toml --home ./ --passwordfile password.txt fee grant --grantee ${GRANTEE_BUNDLE_ACCOUNT} --allowance ${ALLOWANCE}
echo "created bucket and granted permission"
}

CMD=$1
case ${CMD} in
Expand All @@ -54,6 +58,9 @@ case ${CMD} in
--grant)
grant
;;
--all)
all
;;
esac


0 comments on commit 1e47fc8

Please sign in to comment.