openidec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 57373879e58fab7b91dfd45b901b9ed102a9c58a
parent 0ed3e5d93bf6e1004bbf0a4073937b3dac503c9e
Author: Peter Kosyh <p.kosyh@gmail.com>
Date:   Mon, 14 Sep 2020 23:27:54 +0300

fmt and \n problem fixed

Diffstat:
Mii-tool/main.go | 18+++++++++---------
Mii/db.go | 12++++++------
Mii/net.go | 3+++
3 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/ii-tool/main.go b/ii-tool/main.go @@ -171,7 +171,7 @@ Options: dup := 0 fmt.Printf("Pass 1...\n") err := ii.FileLines(*db_opt, func(line string) bool { - nr ++ + nr++ a := strings.Split(line, ":") if len(a) != 2 { ii.Error.Printf("Error in line: %d", nr) @@ -182,8 +182,8 @@ Options: return true } if _, ok := hash[a[0]]; ok { - hash[a[0]] ++ - dup ++ + hash[a[0]]++ + dup++ last[a[0]] = line } else { hash[a[0]] = 1 @@ -196,24 +196,24 @@ Options: } fmt.Printf("Pass 2...\n") nr = 0 - f, err := os.OpenFile(*db_opt + ".new", os.O_CREATE|os.O_WRONLY, 0644) + f, err := os.OpenFile(*db_opt+".new", os.O_CREATE|os.O_WRONLY, 0644) if err != nil { fmt.Printf("Error: %s\n", err) os.Exit(1) } skip := 0 err = ii.FileLines(*db_opt, func(line string) bool { - nr ++ + nr++ a := strings.Split(line, ":") id := a[0] if len(a) != 2 { fmt.Printf("Error in line: %d\n", nr) - skip ++ + skip++ return true } if !ii.IsMsgId(id) { fmt.Printf("Error in line: %d\n", nr) - skip ++ + skip++ return true } if v, ok := hash[id]; !ok || v == 0 { @@ -231,7 +231,7 @@ Options: os.Exit(1) } } else { - skip ++ + skip++ } hash[id] += 1 if hash[id] > 0 { @@ -251,7 +251,7 @@ Options: os.Exit(1) } } - fmt.Printf("%d messages removed. File %s created.\n", skip, *db_opt + ".new") + fmt.Printf("%d messages removed. File %s created.\n", skip, *db_opt+".new") case "fetch": var echolist []string if len(args) < 2 { diff --git a/ii/db.go b/ii/db.go @@ -34,11 +34,11 @@ type Index struct { } type DB struct { - Path string - Idx Index - Sync sync.RWMutex - IdxSync sync.RWMutex - Name string + Path string + Idx Index + Sync sync.RWMutex + IdxSync sync.RWMutex + Name string LockDepth int32 } @@ -237,7 +237,7 @@ func (db *DB) LoadIndex() error { mi.Repto = info[5] if mm, ok := Idx.Hash[mi.Id]; !ok { // new msg Idx.List = append(Idx.List, mi.Id) - nr ++ + nr++ } else { mi.Num = mm.Num } diff --git a/ii/net.go b/ii/net.go @@ -34,6 +34,9 @@ func http_req_lines(url string, fn func(string) bool) error { } line = strings.TrimSuffix(line, "\n") if err == io.EOF { + if line != "" { /* node do not send final \n */ + fn(line) + } break } if !fn(line) {