[#141] Add big object's parts to a lock object's body
All checks were successful
ci/woodpecker/pr/pre-commit Pipeline was successful

That will prevent part/link object from being removed by both an external
`DELETE` call and the object expiration procedure.

Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
Pavel Karpy 2023-03-15 20:21:13 +03:00
parent f111704ceb
commit a626354b1f
2 changed files with 26 additions and 6 deletions

View file

@ -51,6 +51,7 @@ Changelog for FrostFS Node
- Pretty printer of basic ACL in the NeoFS CLI (#2259)
- Adding of public key for nns group `group.frostfs` at init step (#130)
- Iterating over just removed files by FSTree (#98)
- Parts of a locked object could not be removed anymore (#141)
### Removed
### Updated

View file

@ -32,16 +32,35 @@ var objectLockCmd = &cobra.Command{
err := cnr.DecodeString(cidRaw)
commonCmd.ExitOnErr(cmd, "Incorrect container arg: %v", err)
key := key.GetOrGenerate(cmd)
cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC)
oidsRaw, _ := cmd.Flags().GetStringSlice(commonflags.OIDFlag)
lockList := make([]oid.ID, len(oidsRaw))
lockList := make([]oid.ID, 0, len(oidsRaw))
oidM := make(map[oid.ID]struct{})
for i := range oidsRaw {
err = lockList[i].DecodeString(oidsRaw[i])
for i, oidRaw := range oidsRaw {
var oID oid.ID
err = oID.DecodeString(oidRaw)
commonCmd.ExitOnErr(cmd, fmt.Sprintf("Incorrect object arg #%d: %%v", i+1), err)
if _, ok := oidM[oID]; ok {
continue
}
key := key.GetOrGenerate(cmd)
lockList = append(lockList, oID)
oidM[oID] = struct{}{}
for _, relative := range collectObjectRelatives(cmd, cli, cnr, oID) {
if _, ok := oidM[relative]; ok {
continue
}
lockList = append(lockList, relative)
oidM[relative] = struct{}{}
}
}
var idOwner user.ID
user.IDFromKey(&idOwner, key.PublicKey)
@ -81,7 +100,7 @@ var objectLockCmd = &cobra.Command{
obj.SetPayload(lock.Marshal())
var prm internalclient.PutObjectPrm
ReadOrOpenSession(cmd, &prm, key, cnr, nil)
ReadOrOpenSessionViaClient(cmd, &prm, cli, key, cnr, nil)
Prepare(cmd, &prm)
prm.SetHeader(obj)