Skip to content

Commit

Permalink
Merge pull request #20 from TRON-US/pin-rm-force
Browse files Browse the repository at this point in the history
BTFS-654: Add force option on btfs pin rm
  • Loading branch information
taiyangc authored Jan 14, 2020
2 parents 594c1ba + 100b448 commit a664d16
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions options/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type PinLsSettings struct {
// PinRmSettings represents the settings of pin rm command
type PinRmSettings struct {
Recursive bool
Force bool
}

type PinUpdateSettings struct {
Expand Down Expand Up @@ -47,6 +48,7 @@ func PinAddOptions(opts ...PinAddOption) (*PinAddSettings, error) {
func PinRmOptions(opts ...PinRmOption) (*PinRmSettings, error) {
options := &PinRmSettings{
Recursive: true,
Force: false,
}

for _, opt := range opts {
Expand Down Expand Up @@ -129,6 +131,14 @@ func (pinOpts) Recursive(recursive bool) PinAddOption {
}
}

// DurationCount is an option for Pin.Add which specifies count od the time.Duration above.
func (pinOpts) DurationCount(count int64) PinAddOption {
return func(settings *PinAddSettings) error {
settings.DurationCount = count
return nil
}
}

// RmRecursive is an option for Pin.Rm which specifies whether to recursively
// unpin the object linked to by the specified object(s). This does not remove
// indirect pins referenced by other recursive pins.
Expand All @@ -139,10 +149,11 @@ func (pinOpts) RmRecursive(recursive bool) PinRmOption {
}
}

// DurationCount is an option for Pin.Add which specifies count od the time.Duration above.
func (pinOpts) DurationCount(count int64) PinAddOption {
return func(settings *PinAddSettings) error {
settings.DurationCount = count
// RmForce is an option for Pin.Rm which specifies whether to forcibly
// unpin an object, even if constraint is made on the object (such as host-stored file).
func (pinOpts) RmForce(force bool) PinRmOption {
return func(settings *PinRmSettings) error {
settings.Force = force
return nil
}
}
Expand Down

0 comments on commit a664d16

Please sign in to comment.