inspect

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChunkDetailCmd = &cli.Command{
	Name:      "chunkdetail",
	Usage:     "Get details about a specific chunk",
	ArgsUsage: "<chunk_id>",
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		result, err := inspect.GetSourceChunkDetailHandler(
			db,
			c.Args().Get(0),
		)
		if err != nil {
			return err.CliError()
		}

		if c.Bool("json") {
			cliutil.PrintToConsole(result, true)
			return nil
		}

		fmt.Println("Chunk:")
		cliutil.PrintToConsole(result, false)
		fmt.Println("Pieces:")
		cliutil.PrintToConsole(result.Cars, false)
		fmt.Println("Item Parts:")
		cliutil.PrintToConsole(underscore.Map(result.ItemParts, func(i model.ItemPart) ItemPartDetail {
			return ItemPartDetail{
				ID:                        i.ID,
				ItemID:                    i.ItemID,
				Offset:                    i.Offset,
				Length:                    i.Length,
				ItemPartCID:               i.CID,
				SourceID:                  i.Item.SourceID,
				Path:                      i.Item.Path,
				Hash:                      i.Item.Hash,
				Size:                      i.Item.Size,
				LastModifiedTimestampNano: i.Item.LastModifiedTimestampNano,
				ItemCID:                   i.Item.CID,
				DirectoryID:               *i.Item.DirectoryID,
			}
		}), false)
		return nil
	},
}
View Source
var ChunksCmd = &cli.Command{
	Name:      "chunks",
	Usage:     "Get all chunk details of a data source",
	ArgsUsage: "<source_id>",
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		result, err := inspect.GetSourceChunksHandler(
			db,
			c.Args().Get(0),
		)
		if err != nil {
			return err.CliError()
		}

		if c.Bool("json") {
			cliutil.PrintToConsole(result, true)
			return nil
		}
		fmt.Println("Chunks:")
		cliutil.PrintToConsole(result, false)
		fmt.Println("Pieces:")
		var cars []model.Car
		for _, chunk := range result {
			cars = append(cars, chunk.Cars...)
		}
		cliutil.PrintToConsole(cars, false)

		return nil
	},
}
View Source
var DagsCmd = &cli.Command{
	Name:      "dags",
	Usage:     "Get all piece details for generated dags",
	ArgsUsage: "<source_id>",
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		cars, err := inspect.GetDagsHandler(
			db,
			c.Args().Get(0),
		)
		if err != nil {
			return err.CliError()
		}

		cliutil.PrintToConsole(cars, c.Bool("json"))

		return nil
	},
}
View Source
var DirCmd = &cli.Command{
	Name:      "dir",
	Usage:     "Get all item details within a directory of a data source",
	ArgsUsage: "<source_id> <path>",
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		result, err := inspect.GetDirectoryHandler(
			db,
			c.Args().Get(0),
			c.Args().Get(1),
		)
		if err != nil {
			return err.CliError()
		}

		if c.Bool("json") {
			cliutil.PrintToConsole(result, true)
			return nil
		}

		fmt.Println("Current:")
		cliutil.PrintToConsole(result.Current, false)
		fmt.Println("Dirs:")
		cliutil.PrintToConsole(result.Dirs, false)
		fmt.Println("Items:")
		cliutil.PrintToConsole(result.Items, false)
		return nil
	},
}
View Source
var ItemDetailCmd = &cli.Command{
	Name:      "itemdetail",
	Usage:     "Get details about a specific item",
	ArgsUsage: "<item_id>",
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		result, err := inspect.GetSourceItemDetailHandler(
			db,
			c.Args().Get(0),
		)
		if err != nil {
			return err.CliError()
		}

		if c.Bool("json") {
			cliutil.PrintToConsole(result, true)
			return nil
		}

		fmt.Println("Item:")
		cliutil.PrintToConsole(result, false)
		fmt.Println("Item Parts:")
		cliutil.PrintToConsole(result.ItemParts, false)
		return nil
	},
}
View Source
var ItemsCmd = &cli.Command{
	Name:        "items",
	Usage:       "Get all item details of a data source",
	ArgsUsage:   "<source_id>",
	Description: "This command will list all items in a data source. This may be very large list.",
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		result, err := inspect.GetSourceItemsHandler(
			db,
			c.Args().Get(0),
		)
		if err != nil {
			return err.CliError()
		}

		cliutil.PrintToConsole(result, c.Bool("json"))
		return nil
	},
}

Functions

This section is empty.

Types

type ItemPartDetail

type ItemPartDetail struct {
	ID                        uint64    `json:"id"`
	ItemID                    uint64    `json:"itemId"`
	Offset                    int64     `json:"offset"`
	Length                    int64     `json:"length"`
	ItemPartCID               model.CID `json:"itemPartCid"`
	SourceID                  uint32    `json:"sourceId"`
	Path                      string    `json:"path"`
	Hash                      string    `json:"hash"`
	Size                      int64     `json:"size"`
	LastModifiedTimestampNano int64     `json:"lastModified"`
	ItemCID                   model.CID `json:"itemCid"`
	DirectoryID               uint64    `json:"directoryId"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL