mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-24 11:12:14 +01:00
- Fetcher.__fetch_cpio: split cpio request into smaller requests if the server returns code 414
This commit is contained in:
parent
15b27b7ff1
commit
161b9ca274
28
osc/fetch.py
28
osc/fetch.py
@ -5,6 +5,8 @@
|
||||
|
||||
import sys, os
|
||||
import urllib2
|
||||
from urllib import quote_plus
|
||||
|
||||
from urlgrabber.grabber import URLGrabError
|
||||
from urlgrabber.mirror import MirrorGroup
|
||||
from core import makeurl, streamfile
|
||||
@ -89,11 +91,10 @@ class Fetcher:
|
||||
prpap = '%s/%s/%s/%s' % (pac.project, pac.repository, pac.repoarch, pac.repopackage)
|
||||
self.cpio.setdefault(prpap, {})[pac.repofilename] = pac
|
||||
|
||||
def __fetch_cpio(self, apiurl):
|
||||
from urllib import quote_plus
|
||||
for prpap, pkgs in self.cpio.iteritems():
|
||||
project, repo, arch, package = prpap.split('/', 3)
|
||||
query = ['binary=%s' % quote_plus(i) for i in pkgs.keys()]
|
||||
def __download_cpio_archive(self, apiurl, project, repo, arch, package, **pkgs):
|
||||
if not pkgs:
|
||||
return
|
||||
query = ['binary=%s' % quote_plus(i) for i in pkgs]
|
||||
query.append('view=cpio')
|
||||
tmparchive = tmpfile = None
|
||||
try:
|
||||
@ -125,12 +126,29 @@ class Fetcher:
|
||||
if not os.path.isfile(pac.fullfilename):
|
||||
raise oscerr.APIError('failed to fetch file \'%s\': ' \
|
||||
'does not exist in CPIO archive' % pac.repofilename)
|
||||
except URLGrabError, e:
|
||||
if e.errno != 14 or e.code != 414:
|
||||
raise
|
||||
# query str was too large
|
||||
keys = pkgs.keys()
|
||||
if len(keys) == 1:
|
||||
raise oscerr.APIError('unable to fetch cpio archive: server always returns code 414')
|
||||
n = len(pkgs) / 2
|
||||
new_pkgs = dict([(k, pkgs[k]) for k in keys[:n]])
|
||||
self.__download_cpio_archive(apiurl, project, repo, arch, package, **new_pkgs)
|
||||
new_pkgs = dict([(k, pkgs[k]) for k in keys[n:]])
|
||||
self.__download_cpio_archive(apiurl, project, repo, arch, package, **new_pkgs)
|
||||
finally:
|
||||
if not tmparchive is None and os.path.exists(tmparchive):
|
||||
os.unlink(tmparchive)
|
||||
if not tmpfile is None and os.path.exists(tmpfile):
|
||||
os.unlink(tmpfile)
|
||||
|
||||
def __fetch_cpio(self, apiurl):
|
||||
for prpap, pkgs in self.cpio.iteritems():
|
||||
project, repo, arch, package = prpap.split('/', 3)
|
||||
self.__download_cpio_archive(apiurl, project, repo, arch, package, **pkgs)
|
||||
|
||||
def fetch(self, pac, prefix=''):
|
||||
# for use by the failure callback
|
||||
self.curpac = pac
|
||||
|
Loading…
x
Reference in New Issue
Block a user