Move request building within loop to avoid shallow copy reuse between routines
This commit is contained in:
parent
6489774ca1
commit
d8c691af3c
|
@ -122,6 +122,7 @@ func Query(uname string, api_key string, tags []string, j_max Jobs, tout time.Du
|
|||
res_chan := make(chan result)
|
||||
var r_arr []result
|
||||
|
||||
for pid, rpid, ppid := Page(0), Page(0), Page(0); ; {
|
||||
q := &http.Request{
|
||||
URL: &url.URL{
|
||||
Scheme: "https",
|
||||
|
@ -139,7 +140,6 @@ func Query(uname string, api_key string, tags []string, j_max Jobs, tout time.Du
|
|||
}
|
||||
q.URL.RawQuery = uq.Encode()
|
||||
|
||||
for pid, rpid, ppid := Page(0), Page(0), Page(0); ; {
|
||||
go run_job(q, tout, pid, res_chan)
|
||||
pid++
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ func Query(tags Tags, j_max Jobs) (mr []Media, err error) {
|
|||
res_chan := make(chan result)
|
||||
var r_arr []result
|
||||
|
||||
for pid, rpid, ppid := uint(0), uint(0), uint(0); ; {
|
||||
q := &http.Request{
|
||||
URL: &url.URL{
|
||||
Scheme: "https",
|
||||
|
@ -97,7 +98,6 @@ func Query(tags Tags, j_max Jobs) (mr []Media, err error) {
|
|||
qu.Set("tags", strings.Join(tags, " "))
|
||||
q.URL.RawQuery = qu.Encode()
|
||||
|
||||
for pid, rpid, ppid := uint(0), uint(0), uint(0); ; {
|
||||
if pid <= 200 { // API only allows to fetch up to 200 pages per query
|
||||
go run_job(q, pid, res_chan)
|
||||
pid++
|
||||
|
|
Loading…
Reference in New Issue