-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove whopays attribute * Remove dot logger * Fix hashes of test * Remove redundant payer id field * Remove authticket association with readmarker * Fix conflicts * Remove proto file * Update go modules * Generate/Update grpc code * Go mod tidy * Remove payer in test insertion * Make reader pay for read instead of owner * Go mod tidy Co-authored-by: peterlimg <54137706+peterlimg@users.noreply.github.com> Co-authored-by: peterlimg <peterlimg@protonmail.com> Co-authored-by: Lz <imlangzi@qq.com>
- Loading branch information
1 parent
6b072d0
commit 28ea8c0
Showing
45 changed files
with
568 additions
and
1,966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ dev.local/data | |
out/ | ||
**/tmp/ | ||
*.tar.gz | ||
**/descriptor.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 0 additions & 116 deletions
116
code/go/0chain.net/blobbercore/allocation/attributesfilechange.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1 @@ | ||
package allocation | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"path/filepath" | ||
|
||
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference" | ||
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/stats" | ||
"github.com/0chain/blobber/code/go/0chain.net/core/common" | ||
|
||
. "github.com/0chain/blobber/code/go/0chain.net/core/logging" | ||
"go.uber.org/zap" | ||
) | ||
|
||
// The AttributesChange represents file attributes change. | ||
type AttributesChange struct { | ||
ConnectionID string `json:"connection_id"` | ||
AllocationID string `json:"allocation_id"` | ||
Path string `json:"path"` | ||
Attributes *reference.Attributes `json:"attributes"` // new attributes | ||
} | ||
|
||
// ApplyChange processes the attributes changes. | ||
func (ac *AttributesChange) ApplyChange(ctx context.Context, _ *AllocationChange, allocRoot string) (ref *reference.Ref, err error) { | ||
var path, _ = filepath.Split(ac.Path) | ||
path = filepath.Clean(path) | ||
|
||
// root reference | ||
ref, err = reference.GetReferencePath(ctx, ac.AllocationID, ac.Path) | ||
|
||
if err != nil { | ||
return nil, common.NewErrorf("process_attrs_update", | ||
"getting root reference path: %v", err) | ||
} | ||
|
||
var ( | ||
tSubDirs = reference.GetSubDirsFromPath(path) | ||
dirRef = ref | ||
treelevel = 0 | ||
) | ||
dirRef.HashToBeComputed = true | ||
for treelevel < len(tSubDirs) { | ||
var found bool | ||
for _, child := range dirRef.Children { | ||
if child.Type == reference.DIRECTORY && treelevel < len(tSubDirs) { | ||
if child.Name == tSubDirs[treelevel] { | ||
dirRef, found = child, true | ||
dirRef.HashToBeComputed = true | ||
break | ||
} | ||
} | ||
} | ||
if found { | ||
treelevel++ | ||
} else { | ||
return nil, common.NewError("process_attrs_update", | ||
"invalid reference path from the blobber") | ||
} | ||
} | ||
|
||
var idx = -1 | ||
for i, child := range dirRef.Children { | ||
if child.Type == reference.FILE && child.Path == ac.Path { | ||
idx = i | ||
break | ||
} | ||
} | ||
|
||
if idx < 0 { | ||
Logger.Error("error in file attributes update", zap.Any("change", ac)) | ||
return nil, common.NewError("process_attrs_update", | ||
"file to update not found in blobber") | ||
} | ||
|
||
var existingRef = dirRef.Children[idx] | ||
existingRef.WriteMarker = allocRoot | ||
if err = existingRef.SetAttributes(ac.Attributes); err != nil { | ||
return nil, common.NewErrorf("process_attrs_update", | ||
"setting new attributes: %v", err) | ||
} | ||
|
||
existingRef.HashToBeComputed = true | ||
|
||
if _, err := ref.CalculateHash(ctx, true); err != nil { | ||
return nil, common.NewErrorf("process_attrs_update", | ||
"saving updated reference: %v", err) | ||
} | ||
|
||
stats.FileUpdated(ctx, existingRef.ID) | ||
return | ||
} | ||
|
||
// Marshal to JSON-string. | ||
func (ac *AttributesChange) Marshal() (val string, err error) { | ||
var b []byte | ||
if b, err = json.Marshal(ac); err != nil { | ||
return | ||
} | ||
return string(b), nil | ||
} | ||
|
||
// Unmarshal from given JSON-string. | ||
func (ac *AttributesChange) Unmarshal(val string) (err error) { | ||
err = json.Unmarshal([]byte(val), ac) | ||
return | ||
} | ||
|
||
// The DeleteTempFile returns OperationNotApplicable error. | ||
func (ac *AttributesChange) DeleteTempFile() (err error) { | ||
return nil | ||
} | ||
|
||
// The CommitToFileStore does nothing. | ||
func (ac *AttributesChange) CommitToFileStore(_ context.Context) (err error) { | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.