mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-03 09:08:18 -04:00
fix: when just saving a file, open the file in write mode (fixes #99)
This commit is contained in:
parent
a0bcac3904
commit
c040bdedee
@ -32,7 +32,7 @@ func (t *Tracker) OpenSongFile(forced bool) {
|
|||||||
|
|
||||||
func (t *Tracker) SaveSongFile() bool {
|
func (t *Tracker) SaveSongFile() bool {
|
||||||
if p := t.FilePath(); p != "" {
|
if p := t.FilePath(); p != "" {
|
||||||
if f, err := os.Open(p); err == nil {
|
if f, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE, 0644); err == nil {
|
||||||
return t.saveSong(f)
|
return t.saveSong(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,8 +126,14 @@ func (t *Tracker) saveSong(w io.WriteCloser) bool {
|
|||||||
t.Alert.Update(fmt.Sprintf("Error marshaling a song file: %v", err), Error, time.Second*3)
|
t.Alert.Update(fmt.Sprintf("Error marshaling a song file: %v", err), Error, time.Second*3)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
w.Write(contents)
|
if _, err := w.Write(contents); err != nil {
|
||||||
w.Close()
|
t.Alert.Update(fmt.Sprintf("Error writing to file: %v", err), Error, time.Second*3)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if err := w.Close(); err != nil {
|
||||||
|
t.Alert.Update(fmt.Sprintf("Error closing file: %v", err), Error, time.Second*3)
|
||||||
|
return false
|
||||||
|
}
|
||||||
t.SetFilePath(path)
|
t.SetFilePath(path)
|
||||||
t.SetChangedSinceSave(false)
|
t.SetChangedSinceSave(false)
|
||||||
return true
|
return true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user