mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-17 20:54:38 +03:00
Check hashes for xml files
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
import binascii
|
||||||
import itertools
|
import itertools
|
||||||
import operator
|
import operator
|
||||||
import posixpath
|
import posixpath
|
||||||
@@ -35,7 +35,7 @@ from semantic_version import Version as SemanticVersion
|
|||||||
from texttable import Texttable
|
from texttable import Texttable
|
||||||
|
|
||||||
from aqt.exceptions import ArchiveConnectionError, ArchiveDownloadError, ArchiveListError, CliInputError, EmptyMetadata
|
from aqt.exceptions import ArchiveConnectionError, ArchiveDownloadError, ArchiveListError, CliInputError, EmptyMetadata
|
||||||
from aqt.helper import Settings, getUrl, xml_to_modules
|
from aqt.helper import Settings, get_hash, getUrl, xml_to_modules
|
||||||
|
|
||||||
|
|
||||||
class SimpleSpec(SemanticSimpleSpec):
|
class SimpleSpec(SemanticSimpleSpec):
|
||||||
@@ -573,14 +573,13 @@ class MetadataFactory:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fetch_http(rest_of_url: str) -> str:
|
def fetch_http(rest_of_url: str) -> str:
|
||||||
|
timeout = (Settings.connection_timeout, Settings.response_timeout)
|
||||||
|
expected_hash = binascii.unhexlify(get_hash(rest_of_url, "sha256", timeout))
|
||||||
base_urls = Settings.baseurl, random.choice(Settings.fallbacks)
|
base_urls = Settings.baseurl, random.choice(Settings.fallbacks)
|
||||||
for i, base_url in enumerate(base_urls):
|
for i, base_url in enumerate(base_urls):
|
||||||
try:
|
try:
|
||||||
url = posixpath.join(base_url, rest_of_url)
|
url = posixpath.join(base_url, rest_of_url)
|
||||||
return getUrl(
|
return getUrl(url=url, timeout=timeout, expected_hash=expected_hash)
|
||||||
url=url,
|
|
||||||
timeout=(Settings.connection_timeout, Settings.response_timeout),
|
|
||||||
)
|
|
||||||
|
|
||||||
except (ArchiveDownloadError, ArchiveConnectionError) as e:
|
except (ArchiveDownloadError, ArchiveConnectionError) as e:
|
||||||
if i == len(base_urls) - 1:
|
if i == len(base_urls) - 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user