Skip to content

Commit

Permalink
refactor: [minor refactor] remove extra line and return nil to not br…
Browse files Browse the repository at this point in the history
…eak existing mount functionalities

Signed-off-by: Shivanjan Chakravorty <[email protected]>
  • Loading branch information
Glitchfix committed Sep 28, 2023
1 parent 4fb38fa commit 9a01976
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pkg/chattr/chattr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ const (
lsattrCmd = "lsattr"
)

func AddImmutable(path string) (err error) {

func AddImmutable(path string) error {
return ForceAddImmutable(path, false)
}

func ForceAddImmutable(path string, force bool) (err error) {
func ForceAddImmutable(path string, force bool) error {
chattrBin := which(chattrCmd)
if _, err = os.Stat(path); err == nil {
if _, err := os.Stat(path); err == nil {
var cmd *exec.Cmd
if force {
cmd = exec.Command(chattrBin, "+i", "-f", path)
Expand All @@ -46,16 +45,15 @@ func ForceAddImmutable(path string, force bool) (err error) {
}
return fmt.Errorf("%s +i failed: %s. Err: %v", chattrBin, stderr.String(), err)
}
return nil
}

return err
return nil
}

func RemoveImmutable(path string) (err error) {
func RemoveImmutable(path string) error {
return ForceRemoveImmutable(path, false)
}
func ForceRemoveImmutable(path string, force bool) (err error) {
func ForceRemoveImmutable(path string, force bool) error {
chattrBin := which(chattrCmd)
if _, err := os.Stat(path); err == nil {
var cmd *exec.Cmd
Expand All @@ -80,10 +78,9 @@ func ForceRemoveImmutable(path string, force bool) (err error) {
}
return fmt.Errorf("%s -i failed: %s. Err: %v", chattrBin, stderr.String(), err)
}
return nil
}

return err
return nil
}

func IsImmutable(path string) bool {
Expand Down

0 comments on commit 9a01976

Please sign in to comment.