Fix truncation when saving file changes; closes pterodactyl/panel#1956
This commit is contained in:
parent
7321fe1421
commit
46056dbce9
|
@ -204,6 +204,11 @@ func (f *ConfigurationFile) parseXmlFile(path string) error {
|
|||
// Ensure the XML is indented properly.
|
||||
doc.Indent(2)
|
||||
|
||||
// Truncate the file before attempting to write the changes.
|
||||
if err := os.Truncate(path, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Write the XML to the file.
|
||||
_, err = doc.WriteTo(file)
|
||||
|
||||
|
@ -261,6 +266,11 @@ func (f *ConfigurationFile) parseIniFile(path string) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Truncate the file before attempting to write the changes.
|
||||
if err := os.Truncate(path, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := cfg.WriteTo(file); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -387,7 +397,7 @@ func (f *ConfigurationFile) parsePropertiesFile(path string) error {
|
|||
}
|
||||
}
|
||||
|
||||
w, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0644)
|
||||
w, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user