commit a15c090c390c235f0b1e95bb567ca78b42584935
parent b145909149d0cdfcdc3ea3a67a2c44b4589250ab
Author: Peter Kosyh <p.kosyh@gmail.com>
Date: Wed, 9 Sep 2020 09:20:35 +0300
force fetch
Diffstat:
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/ii-tool/main.go b/ii-tool/main.go
@@ -56,6 +56,7 @@ func main() {
db_opt := flag.String("db", "./db", "II database path (directory)")
lim_opt := flag.Int("lim", 0, "Fetch last N messages")
verbose_opt := flag.Bool("v", false, "Verbose")
+ force_opt := flag.Bool("f", false, "Force full sync")
users_opt := flag.String("u", "points.txt", "Users database")
conns_opt := flag.Int("j", 6, "Maximum parallel jobs")
@@ -174,6 +175,9 @@ Options:
fmt.Printf("Can not connect to %s: %s\n", args[1], err)
os.Exit(1)
}
+ if *force_opt {
+ n.Force = true
+ }
if len(args) > 2 {
str := GetFile(args[2])
for _, v := range strings.Split(str, "\n") {
diff --git a/ii/net.go b/ii/net.go
@@ -17,6 +17,7 @@ import (
type Node struct {
Host string
Features map[string]bool
+ Force bool
}
func http_req_lines(url string, fn func(string) bool) error {
@@ -63,14 +64,16 @@ func (n *Node) Fetcher(db *DB, Echo string, limit int, wait *sync.WaitGroup, con
}()
defer wait.Done()
if n.IsFeature("u/e") { /* fast path */
- id, err := http_get_id(n.Host + "/u/e/" + Echo + "/-1:1")
- if !IsMsgId(id) {
- Info.Printf("%s: no valid MsgId", Echo)
- return
- }
- if err == nil && db.Exists(id) != nil { /* no sync needed */
- Info.Printf("%s: no sync needed", Echo)
- return
+ if !n.Force {
+ id, err := http_get_id(n.Host + "/u/e/" + Echo + "/-1:1")
+ if !IsMsgId(id) {
+ Info.Printf("%s: no valid MsgId", Echo)
+ return
+ }
+ if err == nil && db.Exists(id) != nil { /* no sync needed */
+ Info.Printf("%s: no sync needed", Echo)
+ return
+ }
}
if limit < 0 {
limit = -limit