Improved 'keep' files/directory code and fixed said files from being removed as obsolete
This commit is contained in:
parent
c85c9b5d1c
commit
7d577a8dc2
@ -310,6 +310,9 @@ func ReadPackageInfo(contents string, defaultValues bool) (*PackageInfo, error)
|
|||||||
return nil, errors.New("this package contains no type")
|
return nil, errors.New("this package contains no type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for i := 0; i < len(pkgInfo.Keep); i++ {
|
||||||
|
pkgInfo.Keep[i] = strings.TrimPrefix(pkgInfo.Keep[i], "/")
|
||||||
|
}
|
||||||
return &pkgInfo, nil
|
return &pkgInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,14 +371,32 @@ func extractPackage(pkgInfo *PackageInfo, verbose bool, filename, rootDir string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case tar.TypeReg:
|
case tar.TypeReg:
|
||||||
|
skip := false
|
||||||
if _, err := os.Stat(extractFilename); err == nil {
|
if _, err := os.Stat(extractFilename); err == nil {
|
||||||
if slices.Contains(pkgInfo.Keep, trimmedName) {
|
for _, k := range pkgInfo.Keep {
|
||||||
|
if strings.HasSuffix(k, "/") {
|
||||||
|
if strings.HasPrefix(trimmedName, k) {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Println("Skipping File: " + extractFilename + "(File is configured to be kept during installs/updates)")
|
fmt.Println("Skipping File: " + extractFilename + " (Containing directory is set to be kept during installs/updates)")
|
||||||
}
|
}
|
||||||
files = append(files, trimmedName)
|
files = append(files, strings.TrimPrefix(header.Name, "files/"))
|
||||||
|
skip = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if trimmedName == k {
|
||||||
|
if verbose {
|
||||||
|
fmt.Println("Skipping File: " + extractFilename + " (File is configured to be kept during installs/updates)")
|
||||||
|
}
|
||||||
|
files = append(files, strings.TrimPrefix(header.Name, "files/"))
|
||||||
|
skip = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if skip {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
err := os.Remove(extractFilename)
|
err := os.Remove(extractFilename)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user