|
|
@ -42,29 +42,34 @@ func loadjson(stor storage.Storage, filename string) error { |
|
|
|
max = e.ID |
|
|
|
} |
|
|
|
|
|
|
|
qurl := &qurl.QURL{ |
|
|
|
q := &qurl.QURL{ |
|
|
|
ID: e.ID, |
|
|
|
URL: e.URL, |
|
|
|
} |
|
|
|
|
|
|
|
if e.Date.Date > 0 { |
|
|
|
qurl.Created = time.Unix((e.Date.Date / 1000), 0) |
|
|
|
q.Created = time.Unix((e.Date.Date / 1000), 0) |
|
|
|
} |
|
|
|
|
|
|
|
if e.IP != "" { |
|
|
|
qurl.IP = net.ParseIP(e.IP) |
|
|
|
q.IP = net.ParseIP(e.IP) |
|
|
|
} |
|
|
|
|
|
|
|
if e.Browser != "" { |
|
|
|
qurl.Browser = e.Browser |
|
|
|
q.Browser = e.Browser |
|
|
|
} |
|
|
|
|
|
|
|
err := stor.AddQURL(qurl) |
|
|
|
err := q.CheckValid() |
|
|
|
if err != nil { |
|
|
|
fmt.Printf("\nError adding qurl: %s\n", err.Error()) |
|
|
|
fmt.Printf("\nValidation failure: %s\n", err.Error()) |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
err = stor.AddQURL(q) |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("AddQURL() Database error: %s", err.Error()) |
|
|
|
} |
|
|
|
|
|
|
|
count++ |
|
|
|
if (count % 100) == 0 { |
|
|
|
fmt.Printf("*") |
|
|
|