Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions code/go/0chain.net/blobbercore/filestore/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (fs *FileStore) DeletePreCommitDir(allocID string) error {
return nil
}

func (fs *FileStore) CommitWrite(allocID, conID string, fileData *FileInputData) (bool, error) {
func (fs *FileStore) CommitWrite(allocID, conID string, fileData *FileInputData) (_ bool, err error) {

logging.Logger.Info("Committing write", zap.String("allocation_id", allocID), zap.Any("file_data", fileData))
filePathHash := encryption.Hash(fileData.Path)
Expand All @@ -198,7 +198,7 @@ func (fs *FileStore) CommitWrite(allocID, conID string, fileData *FileInputData)

preCommitPath := fs.getPreCommitPathForFile(allocID, fileHash, VERSION)

err := createDirs(filepath.Dir(preCommitPath))
err = createDirs(filepath.Dir(preCommitPath))
if err != nil {
return false, common.NewError("blob_object_precommit_dir_creation_error", err.Error())
}
Expand Down Expand Up @@ -288,12 +288,14 @@ func (fs *FileStore) CommitWrite(allocID, conID string, fileData *FileInputData)
validationRoot := hex.EncodeToString(validationRootBytes)
elapsedRoot := time.Since(now) - elapsedWait
if fmtRoot != fileData.FixedMerkleRoot {
return false, common.NewError("fixed_merkle_root_mismatch",
err = common.NewError("fixed_merkle_root_mismatch",
fmt.Sprintf("Expected %s got %s", fileData.FixedMerkleRoot, fmtRoot))
return false, err
}
if validationRoot != fileData.ValidationRoot {
return false, common.NewError("validation_root_mismatch",
err = common.NewError("validation_root_mismatch",
"calculated validation root does not match with client's validation root")
return false, err
}

err = os.Rename(tempFilePath, preCommitPath)
Expand Down