fix/small-object-parts-locking #141
2 changed files with 26 additions and 6 deletions
|
@ -51,6 +51,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
|
||||||
|
|
|
@ -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)
|
||||||
}
|
|
||||||
|
|
||||||
key := key.GetOrGenerate(cmd)
|
if _, ok := oidM[oID]; ok {
|
||||||
|
|||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue
Seems like a separate feature?
well, could be considered so. i just imagined some "responsible" user that looks for all the parts of a big object and passes all of them to the
object lock
cmd. a separate commit for that?