Fixed major bug where deleting obsolete files would delete directories with other files inside them which could brick your system
This commit is contained in:
parent
6472a113cf
commit
c8fc1b902c
@ -591,11 +591,33 @@ func InstallPackage(filename, installDir string, force, binaryPkgFromSrc, keepTe
|
||||
if len(filesDiff) != 0 {
|
||||
fmt.Println("Removing obsolete files")
|
||||
for _, f := range filesDiff {
|
||||
err := os.RemoveAll(path.Join(installDir, f))
|
||||
f = path.Join(installDir, f)
|
||||
stat, err := os.Lstat(f)
|
||||
if os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("Removing: " + path.Join(installDir, f))
|
||||
if stat.IsDir() {
|
||||
dir, err := os.ReadDir(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(dir) == 0 {
|
||||
fmt.Println("Removing: " + f)
|
||||
err := os.Remove(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Removing: " + f)
|
||||
err := os.Remove(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
2
main.go
2
main.go
@ -17,7 +17,7 @@ import (
|
||||
/* A simple-to-use package manager */
|
||||
/* ---------------------------------- */
|
||||
|
||||
var bpmVer = "0.1.4"
|
||||
var bpmVer = "0.1.5"
|
||||
|
||||
var subcommand = "help"
|
||||
var subcommandArgs []string
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: bpm
|
||||
description: The Bubble Package Manager
|
||||
version: 0.1.4
|
||||
version: 0.1.5
|
||||
url: https://gitlab.com/bubble-package-manager/bpm/
|
||||
license: GPL3
|
||||
architecture: x86_64
|
||||
|
Loading…
x
Reference in New Issue
Block a user