-
Notifications
You must be signed in to change notification settings - Fork 11
/
remove.go
47 lines (42 loc) · 1.15 KB
/
remove.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package dataprep
import (
"github.com/cockroachdb/errors"
"github.com/data-preservation-programs/singularity/cmd/cliutil"
"github.com/data-preservation-programs/singularity/database"
"github.com/data-preservation-programs/singularity/handler/dataprep"
"github.com/urfave/cli/v2"
)
var RemoveCmd = &cli.Command{
Name: "remove",
Usage: "Remove a preparation",
Description: `This will remove all relevant information, including:
* All related jobs
* All related piece info
* Mapping used for Inline Preparation
* All File and Directory data and CIDs
* All Schedules
This will not remove
* All deals ever made`,
ArgsUsage: "<name|id>",
Before: cliutil.CheckNArgs,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "cars",
Usage: "Also remove prepared CAR files",
},
},
Action: func(c *cli.Context) error {
db, closer, err := database.OpenFromCLI(c)
if err != nil {
return errors.WithStack(err)
}
defer closer.Close()
removeCars := c.Bool("cars")
err = dataprep.Default.RemovePreparationHandler(
c.Context, db, c.Args().Get(0),
dataprep.RemoveRequest{
RemoveCars: removeCars,
})
return errors.WithStack(err)
},
}