mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-11 10:31:30 +00:00
Merge remote-tracking branch 'andersson123/no-content-length-check-checksum-instead'
Modify britney to use the database checksum instead of content-length header from apache2.
This commit is contained in:
commit
9398f75d21
@ -30,6 +30,7 @@ import re
|
|||||||
import socket
|
import socket
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import sys
|
import sys
|
||||||
|
import hashlib
|
||||||
import time
|
import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
@ -169,8 +170,10 @@ class AutopkgtestPolicy(BasePolicy):
|
|||||||
|
|
||||||
def fetch_db(self):
|
def fetch_db(self):
|
||||||
f = None
|
f = None
|
||||||
|
local_db_sha = hashlib.sha256()
|
||||||
try:
|
try:
|
||||||
f = self.download_retry(self.options.adt_db_url)
|
f = self.download_retry(self.options.adt_db_url)
|
||||||
|
chksum = self.download_retry(self.options.adt_db_url + ".sha256").read().rstrip()
|
||||||
http_code = f.getcode()
|
http_code = f.getcode()
|
||||||
# file:/// urls don't have the http niceties
|
# file:/// urls don't have the http niceties
|
||||||
if not http_code or http_code == 200:
|
if not http_code or http_code == 200:
|
||||||
@ -180,10 +183,10 @@ class AutopkgtestPolicy(BasePolicy):
|
|||||||
data=f.read(2048*1024)
|
data=f.read(2048*1024)
|
||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
|
local_db_sha.update(data)
|
||||||
f_out.write(data)
|
f_out.write(data)
|
||||||
content_length = f.getheader('content-length')
|
if http_code and local_db_sha.hexdigest() != chksum:
|
||||||
if http_code and content_length and os.path.getsize(new_file) != content_length:
|
self.logger.info("autopkgtest.db local checksum does not match downloaded checksum!")
|
||||||
self.logger.info('Short read downloading autopkgtest results')
|
|
||||||
os.unlink(new_file)
|
os.unlink(new_file)
|
||||||
else:
|
else:
|
||||||
os.rename(new_file, self.database_path)
|
os.rename(new_file, self.database_path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user