]> 127.0.0.1 Git - part/.git/commitdiff
fix v0.10.10
authorqydysky <32743305+qydysky@users.noreply.github.com>
Sun, 16 Oct 2022 06:44:44 +0000 (14:44 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Sun, 16 Oct 2022 06:44:44 +0000 (14:44 +0800)
file/FileWR.go
file/FileWR_test.go

index 8090a593b7df9bcd0fead5ff53b3b112635d8954..add377088113cfc56d81ee0be0ade3b6b6cd65f7 100644 (file)
@@ -233,12 +233,8 @@ func (t *File) getRWCloser() {
                        if f, e := os.Create(t.Config.FilePath); e != nil {
                                panic(e)
                        } else {
-                               if t.Config.CurIndex != 0 {
-                                       whenc := 0
-                                       if t.Config.CurIndex < 0 {
-                                               whenc = 2
-                                       }
-                                       t.Config.CurIndex, e = f.Seek(t.Config.CurIndex, whenc)
+                               if t.Config.CurIndex > 0 {
+                                       t.Config.CurIndex, e = f.Seek(t.Config.CurIndex, 0)
                                        if e != nil {
                                                panic(e)
                                        }
index 7291671a6b1b11b53a798ff46a3a4d0276735e91..91e1851a7b04ae08b1435dc9d102597f3ac22b15 100644 (file)
@@ -11,7 +11,7 @@ import (
 )
 
 func TestWriteReadDelSync(t *testing.T) {
-       f := New("test/rwd.txt", 0, true)
+       f := New("test/rwd.txt", -1, true)
        if i, e := f.Write([]byte("sss"), true); i == 0 || e != nil {
                t.Fatal(e)
        }
@@ -20,10 +20,8 @@ func TestWriteReadDelSync(t *testing.T) {
        if i, e := f.Read(buf); i == 0 || e != nil {
                t.Fatal(i, e)
        } else {
-               for _, v := range buf {
-                       if v != 's' {
-                               t.Fatal(v)
-                       }
+               if !bytes.Equal(buf[:i], []byte("sss")) {
+                       t.Fatal(string(buf[:i]), e)
                }
        }