[#141] Add big object's parts to a lock object's body

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 committed by Gitea
parent a5ece7889d
commit 3c7ed21f74
2 changed files with 26 additions and 6 deletions

View file

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

View file

@ -32,16 +32,35 @@ var objectLockCmd = &cobra.Command{
err := cnr.DecodeString(cidRaw) err := cnr.DecodeString(cidRaw)
commonCmd.ExitOnErr(cmd, "Incorrect container arg: %v", err) 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) 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 { for i, oidRaw := range oidsRaw {
err = lockList[i].DecodeString(oidsRaw[i]) var oID oid.ID
err = oID.DecodeString(oidRaw)
commonCmd.ExitOnErr(cmd, fmt.Sprintf("Incorrect object arg #%d: %%v", i+1), err) 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 var idOwner user.ID
user.IDFromKey(&idOwner, key.PublicKey) user.IDFromKey(&idOwner, key.PublicKey)
@ -81,7 +100,7 @@ var objectLockCmd = &cobra.Command{
obj.SetPayload(lock.Marshal()) obj.SetPayload(lock.Marshal())
var prm internalclient.PutObjectPrm var prm internalclient.PutObjectPrm
ReadOrOpenSession(cmd, &prm, key, cnr, nil) ReadOrOpenSessionViaClient(cmd, &prm, cli, key, cnr, nil)
Prepare(cmd, &prm) Prepare(cmd, &prm)
prm.SetHeader(obj) prm.SetHeader(obj)