]> git.r.bdr.sh - rbdr/mobius/commitdiff
Fix corrupt file info forks
authorJeff Halter <redacted>
Mon, 17 Jun 2024 20:47:32 +0000 (13:47 -0700)
committerJeff Halter <redacted>
Mon, 17 Jun 2024 20:49:39 +0000 (13:49 -0700)
This fixes a bug that happens when:

1. Optional "Enable Resource Forks" feature is true
2. A file comment is added
3. The comment is updated to be shorter than the original

The expected behavior is that the hidden .info file is replaced with the new data, but this wasn't happening because the file flag was not set to truncate on write.

hotline/file_wrapper.go

index a26c45a4a53494d3ee2cde758b62a20c915334ef..997325a1adeda1b6ca54a644edbb7a68fe66a8a8 100644 (file)
@@ -114,7 +114,7 @@ func (f *fileWrapper) rsrcForkWriter() (io.WriteCloser, error) {
 }
 
 func (f *fileWrapper) infoForkWriter() (io.WriteCloser, error) {
-       file, err := os.OpenFile(f.infoPath, os.O_CREATE|os.O_WRONLY, 0644)
+       file, err := os.OpenFile(f.infoPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
        if err != nil {
                return nil, err
        }