Lines Matching refs:tr

340 ta_filename(const struct tarepo *tr)  in ta_filename()  argument
346 file = strrchr(tr->uri[0], '/'); in ta_filename()
349 if (asprintf(&nfile, "%s%s", tr->basedir, file) == -1) in ta_filename()
356 ta_fetch(struct tarepo *tr) in ta_fetch() argument
359 for (; tr->uriidx < tr->num_uris; tr->uriidx++) { in ta_fetch()
360 if (strncasecmp(tr->uri[tr->uriidx], in ta_fetch()
366 if (tr->uriidx >= tr->num_uris) { in ta_fetch()
367 tr->state = REPO_FAILED; in ta_fetch()
368 logx("ta/%s: fallback to cache", tr->descr); in ta_fetch()
370 repo_done(tr, 0); in ta_fetch()
374 logx("ta/%s: pulling from %s", tr->descr, tr->uri[tr->uriidx]); in ta_fetch()
376 if (strncasecmp(tr->uri[tr->uriidx], RSYNC_PROTO, in ta_fetch()
382 rsync_fetch(tr->id, tr->uri[tr->uriidx], tr->basedir, NULL); in ta_fetch()
387 temp = ta_filename(tr); in ta_fetch()
394 http_finish(tr->id, HTTP_FAILED, NULL); in ta_fetch()
399 http_fetch(tr->id, tr->uri[tr->uriidx], NULL, fd); in ta_fetch()
406 struct tarepo *tr; in ta_get() local
410 if ((tr = calloc(1, sizeof(*tr))) == NULL) in ta_get()
413 tr->id = ++repoid; in ta_get()
414 SLIST_INSERT_HEAD(&tarepos, tr, entry); in ta_get()
416 if ((tr->descr = strdup(tal->descr)) == NULL) in ta_get()
418 tr->basedir = repo_dir(tal->descr, ".ta", 0); in ta_get()
421 if (mkpath(tr->basedir) == -1) { in ta_get()
422 warn("mkpath %s", tr->basedir); in ta_get()
423 tr->state = REPO_FAILED; in ta_get()
424 repo_done(tr, 0); in ta_get()
425 return tr; in ta_get()
429 tr->num_uris = tal->num_uris; in ta_get()
430 tr->uri = tal->uri; in ta_get()
434 ta_fetch(tr); in ta_get()
436 return tr; in ta_get()
442 struct tarepo *tr; in ta_find() local
444 SLIST_FOREACH(tr, &tarepos, entry) in ta_find()
445 if (id == tr->id) in ta_find()
447 return tr; in ta_find()
453 struct tarepo *tr; in ta_free() local
455 while ((tr = SLIST_FIRST(&tarepos)) != NULL) { in ta_free()
457 free(tr->descr); in ta_free()
458 free(tr->basedir); in ta_free()
459 free(tr->uri); in ta_free()
460 free(tr); in ta_free()
1032 struct tarepo *tr; in rsync_finish() local
1034 tr = ta_find(id); in rsync_finish()
1035 if (tr != NULL) { in rsync_finish()
1037 if (tr->state != REPO_LOADING) in rsync_finish()
1040 logx("ta/%s: loaded from network", tr->descr); in rsync_finish()
1042 tr->state = REPO_DONE; in rsync_finish()
1043 repo_done(tr, 1); in rsync_finish()
1045 warnx("ta/%s: load from network failed", tr->descr); in rsync_finish()
1047 tr->uriidx++; in rsync_finish()
1048 ta_fetch(tr); in rsync_finish()
1117 struct tarepo *tr; in http_finish() local
1119 tr = ta_find(id); in http_finish()
1120 if (tr == NULL) { in http_finish()
1127 if (tr->state != REPO_LOADING) in http_finish()
1132 logx("ta/%s: loaded from network", tr->descr); in http_finish()
1133 tr->state = REPO_DONE; in http_finish()
1135 repo_done(tr, 1); in http_finish()
1137 remove_contents(tr->basedir); in http_finish()
1139 tr->uriidx++; in http_finish()
1140 warnx("ta/%s: load from network failed", tr->descr); in http_finish()
1141 ta_fetch(tr); in http_finish()
1374 const struct tarepo *tr = rp->ta; in repo_proto() local
1375 if (tr->uriidx < tr->num_uris && in repo_proto()
1376 strncasecmp(tr->uri[tr->uriidx], RSYNC_PROTO, in repo_proto()