add left pack algo
This commit is contained in:
@ -28,6 +28,18 @@ func plan() *cli.Command {
|
||||
Aliases: []string{"v"},
|
||||
Value: false,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "left-pack",
|
||||
Usage: "Use the left-pack algorithm to calculate partitions",
|
||||
Aliases: []string{"l"},
|
||||
Value: false,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "reset",
|
||||
Usage: "Reset the database before planning partitions",
|
||||
Aliases: []string{"r"},
|
||||
Value: false,
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
|
||||
@ -42,6 +54,13 @@ func plan() *cli.Command {
|
||||
panic(fmt.Errorf("error migrating db: %w", err))
|
||||
}
|
||||
|
||||
if c.Bool("reset") {
|
||||
err = store.RemovePartitionAssignment()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error resetting partitions in the db: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
size := int64(4600000000) // size of a single layer DVD
|
||||
targetSize := c.String("targetSize")
|
||||
switch targetSize {
|
||||
@ -76,9 +95,20 @@ func plan() *cli.Command {
|
||||
fmt.Printf("Target Size: %v\n", humanize.Bytes(uint64(size)))
|
||||
fmt.Println("Calculating partitions...")
|
||||
|
||||
partitions, err := partitioner.CalculatePartitions(store, size)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error calculating partitions: %w", err)
|
||||
var partitions [][]types.FileMetadata
|
||||
|
||||
if !c.Bool("left-pack") {
|
||||
partitions, err = partitioner.CalculatePartitions(store, size)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error calculating partitions: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if c.Bool("left-pack") {
|
||||
partitions, err = partitioner.CalculatePartitionsLeftPack(store, size)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error calculating partitions: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
for i, partition := range partitions {
|
||||
|
Reference in New Issue
Block a user