mirror of
https://github.com/Jguer/yay
synced 2024-09-14 13:51:12 +00:00
Prevent file corruption by truncating the files
This commit is contained in:
parent
878c606556
commit
34d0f372fd
|
@ -87,7 +87,7 @@ func readAlpmConfig(pacmanconf string) (conf alpm.PacmanConfig, err error) {
|
||||||
func (config *Configuration) saveConfig() error {
|
func (config *Configuration) saveConfig() error {
|
||||||
config.NoConfirm = false
|
config.NoConfirm = false
|
||||||
marshalledinfo, _ := json.MarshalIndent(config, "", "\t")
|
marshalledinfo, _ := json.MarshalIndent(config, "", "\t")
|
||||||
in, err := os.OpenFile(configFile, os.O_RDWR|os.O_CREATE, 0644)
|
in, err := os.OpenFile(configFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
2
vcs.go
2
vcs.go
|
@ -129,7 +129,7 @@ func saveVCSInfo() error {
|
||||||
if err != nil || string(marshalledinfo) == "null" {
|
if err != nil || string(marshalledinfo) == "null" {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
in, err := os.OpenFile(vcsFile, os.O_RDWR|os.O_CREATE, 0644)
|
in, err := os.OpenFile(vcsFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue