mirror of
https://github.com/mudler/luet.git
synced 2025-09-03 08:14:46 +00:00
tarModifierWrapperFunc: Fix config protect filename
This commit is contained in:
@@ -291,22 +291,31 @@ func tarModifierWrapperFunc(dst, path string, header *tar.Header, content io.Rea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch header.Typeflag {
|
// If file is not present on archive but is defined on mods
|
||||||
case tar.TypeReg:
|
// I receive the callback. Prevent nil exception.
|
||||||
destPath = filepath.Join(dst, path)
|
if header != nil {
|
||||||
default:
|
switch header.Typeflag {
|
||||||
// Nothing to do. I return original reader
|
case tar.TypeReg:
|
||||||
return header, buffer.Bytes(), nil
|
destPath = filepath.Join(dst, path)
|
||||||
}
|
default:
|
||||||
|
// Nothing to do. I return original reader
|
||||||
|
return header, buffer.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Check if exists
|
// Check if exists
|
||||||
if helpers.Exists(destPath) {
|
if helpers.Exists(destPath) {
|
||||||
for i := 1; i < 1000; i++ {
|
for i := 1; i < 1000; i++ {
|
||||||
name := filepath.Join(dst, filepath.Join(filepath.Dir(path), fmt.Sprintf("_cfg%04d_%s", i, filepath.Base(path))))
|
name := filepath.Join(dst, filepath.Join(filepath.Dir(path), fmt.Sprintf("._cfg%04d_%s", i, filepath.Base(path))))
|
||||||
if helpers.Exists(name) {
|
if helpers.Exists(name) {
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
return &tar.Header{
|
||||||
|
Mode: header.Mode,
|
||||||
|
Typeflag: header.Typeflag,
|
||||||
|
PAXRecords: header.PAXRecords,
|
||||||
|
Name: name,
|
||||||
|
}, buffer.Bytes(), nil
|
||||||
}
|
}
|
||||||
return &tar.Header{Mode: header.Mode, Typeflag: header.Typeflag, Name: name}, buffer.Bytes(), nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user