Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Changelog for NeoFS Node

### Changed
- SN returns unsigned responses to requests with API >= `v2.22` (#3785)
- Move lens `write-cache` `get`/`list` commands into `fstree` section in CLI (#3838)

### Removed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package writecache
package fstree

import (
"fmt"
Expand All @@ -11,7 +11,7 @@ import (
var getCMD = &cobra.Command{
Use: "get",
Short: "Object inspection",
Long: `Get specific object from a write-cache.`,
Long: `Get specific object from FSTree.`,
Args: cobra.NoArgs,
RunE: getFunc,
}
Expand All @@ -21,21 +21,22 @@ func init() {
common.AddComponentPathFlag(getCMD, &vPath)
common.AddOutputFileFlag(getCMD, &vOut)
common.AddPayloadOnlyFlag(getCMD, &vPayloadOnly)
AddDepthFlag(getCMD, &vDepth)
}

func getFunc(cmd *cobra.Command, _ []string) error {
wc, err := openWC()
fst, err := openFSTree()
if err != nil {
return err
}
defer wc.Close()
defer fst.Close()

addr, err := oid.DecodeAddressString(vAddress)
if err != nil {
return fmt.Errorf("invalid address: %w", err)
}

obj, err := wc.Get(addr)
obj, err := fst.Get(addr)
if err != nil {
return fmt.Errorf("could not fetch object: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package writecache
package fstree

import (
"fmt"
Expand All @@ -12,33 +12,34 @@ import (
var listCMD = &cobra.Command{
Use: "list",
Short: "Object listing",
Long: `List all objects stored in a write-cache.`,
Long: `List all objects stored in FSTree.`,
Args: cobra.NoArgs,
RunE: listFunc,
}

func init() {
common.AddComponentPathFlag(listCMD, &vPath)
AddDepthFlag(listCMD, &vDepth)
}

func listFunc(cmd *cobra.Command, _ []string) error {
// other targets can be supported
w := cmd.OutOrStderr()

wAddr := func(addr oid.Address, _ []byte) error {
_, err := io.WriteString(w, fmt.Sprintf("%s\n", addr))
wAddr := func(addr oid.Address) error {
_, err := io.WriteString(w, addr.EncodeToString()+"\n")
return err
}

wc, err := openWC()
fst, err := openFSTree()
if err != nil {
return err
}
defer wc.Close()
defer fst.Close()

err = wc.Iterate(wAddr, true)
err = fst.IterateAddresses(wAddr, true)
if err != nil {
return fmt.Errorf("write-cache iterator failure: %w", err)
return fmt.Errorf("fstree iterator failure: %w", err)
}
return nil
}
13 changes: 12 additions & 1 deletion cmd/neofs-lens/internal/fstree/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import (
)

var (
vPath string
vAddress string
vPath string
vOut string
vPayloadOnly bool
vDepth uint64
)

// Root defines root command for operations with FSTree.
Expand All @@ -20,13 +24,20 @@ var Root = &cobra.Command{

func init() {
Root.AddCommand(cleanupCMD)
Root.AddCommand(getCMD)
Root.AddCommand(listCMD)
}

func AddDepthFlag(cmd *cobra.Command, depth *uint64) {
cmd.Flags().Uint64VarP(depth, "depth", "d", 4, "FSTree depth, for write-cache 1 must be used")
}

// openFSTree opens and returns fstree.FSTree located in vPath.
func openFSTree() (*fstree.FSTree, error) {
fst := fstree.New(
fstree.WithPath(vPath),
fstree.WithPerm(0600),
fstree.WithDepth(vDepth),
)

var compressCfg compression.Config
Expand Down
38 changes: 0 additions & 38 deletions cmd/neofs-lens/internal/writecache/root.go

This file was deleted.

2 changes: 0 additions & 2 deletions cmd/neofs-lens/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal/meta"
"github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal/object"
"github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal/storage"
"github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal/writecache"
"github.com/nspcc-dev/neofs-node/misc"
"github.com/nspcc-dev/neofs-node/pkg/util/gendoc"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -40,7 +39,6 @@ func init() {
command.Flags().Bool("version", false, "Application version")
command.AddCommand(
meta.Root,
writecache.Root,
storage.Root,
object.Root,
fstree.Root,
Expand Down
Loading