Skip to content

Commit

Permalink
fix existing delete and error for renaming same file
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 committed Jun 14, 2024
1 parent 4b2db5a commit 422337a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 1 addition & 3 deletions zboxcore/sdk/multi_operation_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ func (mo *MultiOperation) Process() error {
fmt.Sprintf("Multioperation failed. Required consensus %d got %d. Major error: %s",
mo.consensusThresh, mo.operationMask.CountOnes(), majorErr.Error()))
}
return errors.New("consensus_not_met",
fmt.Sprintf("Multioperation failed. Required consensus %d got %d",
mo.consensusThresh, mo.operationMask.CountOnes()))
return nil
}

// Take transpose of mo.change because it will be easier to iterate mo if it contains blobber changes
Expand Down
6 changes: 4 additions & 2 deletions zboxcore/sdk/renameworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"mime/multipart"
"net/http"
"path/filepath"
"sync"
"time"

Expand Down Expand Up @@ -301,8 +302,6 @@ type RenameOperation struct {
}

func (ro *RenameOperation) Process(allocObj *Allocation, connectionID string) ([]fileref.RefEntity, zboxutil.Uint128, error) {

l.Logger.Info("Started Rename Process with Connection Id", connectionID)
// make renameRequest object
rR := &RenameRequest{
allocationObj: allocObj,
Expand All @@ -319,6 +318,9 @@ func (ro *RenameOperation) Process(allocObj *Allocation, connectionID string) ([
wg: &sync.WaitGroup{},
consensus: Consensus{RWMutex: &sync.RWMutex{}},
}
if filepath.Base(ro.remotefilepath) == ro.newName {
return nil, ro.renameMask, errors.New("invalid_operation", "Cannot rename to same name")
}
rR.consensus.fullconsensus = ro.consensus.fullconsensus
rR.consensus.consensusThresh = ro.consensus.consensusThresh

Expand Down

0 comments on commit 422337a

Please sign in to comment.