Skip to content

Commit c69bd00

Browse files
author
Cloud Composer Team
committed
Backport "Correctly test os.stat().st_size"
apache/airflow#3843 Change-Id: I95e09cb68a2b813c2eeb487ee4e1707c9eb92dd5 GitOrigin-RevId: dbd8882bf86297d285a8fc5549ce80da0d8a81a4
1 parent 43f27a8 commit c69bd00

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

airflow/contrib/operators/dataflow_operator.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20+
import os
2021
import re
2122
import uuid
2223
import copy
@@ -358,7 +359,7 @@ def google_cloud_to_local(self, file_name):
358359
# Extracts bucket_id and object_id by first removing 'gs://' prefix and
359360
# then split the remaining by path delimiter '/'.
360361
path_components = file_name[self.GCS_PREFIX_LENGTH:].split('/')
361-
if path_components < 2:
362+
if len(path_components) < 2:
362363
raise Exception(
363364
'Invalid Google Cloud Storage (GCS) object path: {}.'
364365
.format(file_name))
@@ -369,7 +370,7 @@ def google_cloud_to_local(self, file_name):
369370
path_components[-1])
370371
file_size = self._gcs_hook.download(bucket_id, object_id, local_file)
371372

372-
if file_size > 0:
373+
if os.stat(local_file).st_size > 0:
373374
return local_file
374375
raise Exception(
375376
'Failed to download Google Cloud Storage GCS object: {}'

0 commit comments

Comments
 (0)