@ -761,6 +761,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
object_name = dep_value [ ' object_name ' ] ,
object_name = dep_value [ ' object_name ' ] ,
sha256sum = dep_value [ ' sha256sum ' ] ,
sha256sum = dep_value [ ' sha256sum ' ] ,
output_file = dep_value . get ( ' output_file ' ) ,
output_file = dep_value . get ( ' output_file ' ) ,
size_bytes = dep_value [ ' size_bytes ' ] ,
custom_vars = self . custom_vars ,
custom_vars = self . custom_vars ,
should_process = should_process ,
should_process = should_process ,
relative = use_relative_paths ,
relative = use_relative_paths ,
@ -2504,11 +2505,13 @@ class GcsDependency(Dependency):
""" A Dependency object that represents a single GCS bucket and object """
""" A Dependency object that represents a single GCS bucket and object """
def __init__ ( self , parent , name , bucket , object_name , sha256sum ,
def __init__ ( self , parent , name , bucket , object_name , sha256sum ,
output_file , custom_vars , should_process , relative , condition ) :
output_file , size_bytes , custom_vars , should_process , relative ,
condition ) :
self . bucket = bucket
self . bucket = bucket
self . object_name = object_name
self . object_name = object_name
self . sha256sum = sha256sum
self . sha256sum = sha256sum
self . output_file = output_file
self . output_file = output_file
self . size_bytes = size_bytes
url = ' gs:// {bucket} / {object_name} ' . format (
url = ' gs:// {bucket} / {object_name} ' . format (
bucket = self . bucket ,
bucket = self . bucket ,
object_name = self . object_name ,
object_name = self . object_name ,
@ -2625,10 +2628,13 @@ class GcsDependency(Dependency):
gsutil . check_call ( ' cp ' , gcs_url , output_file )
gsutil . check_call ( ' cp ' , gcs_url , output_file )
calculated_sha256sum = ' '
calculated_sha256sum = ' '
calculated_size_bytes = None
if os . getenv ( ' GCLIENT_TEST ' ) == ' 1 ' :
if os . getenv ( ' GCLIENT_TEST ' ) == ' 1 ' :
calculated_sha256sum = ' abcd123 '
calculated_sha256sum = ' abcd123 '
calculated_size_bytes = 10000
else :
else :
calculated_sha256sum = self . GetSha256Sum ( output_file )
calculated_sha256sum = self . GetSha256Sum ( output_file )
calculated_size_bytes = os . path . getsize ( output_file )
if calculated_sha256sum != self . sha256sum :
if calculated_sha256sum != self . sha256sum :
raise Exception ( ' sha256sum does not match calculated hash. '
raise Exception ( ' sha256sum does not match calculated hash. '
@ -2637,6 +2643,13 @@ class GcsDependency(Dependency):
calculated = calculated_sha256sum ,
calculated = calculated_sha256sum ,
) )
) )
if calculated_size_bytes != self . size_bytes :
raise Exception ( ' size_bytes does not match calculated size bytes. '
' {original} vs {calculated} ' . format (
original = self . size_bytes ,
calculated = calculated_size_bytes ,
) )
if tarfile . is_tarfile ( output_file ) :
if tarfile . is_tarfile ( output_file ) :
with tarfile . open ( output_file , ' r:* ' ) as tar :
with tarfile . open ( output_file , ' r:* ' ) as tar :
tar . extractall ( path = output_dir )
tar . extractall ( path = output_dir )