@@ -254,24 +254,13 @@ def rename(self, source_file_names, destination_file_names):
254254 gcs_batches .append (gcs_current_batch )
255255
256256 # Execute GCS renames if any and return exceptions.
257- exceptions = {}
258- for batch in gcs_batches :
259- copy_statuses = self ._gcsIO ().copy_batch (batch )
260- copy_succeeded = []
261- for src , dest , exception in copy_statuses :
262- if exception :
263- exceptions [(src , dest )] = exception
264- else :
265- copy_succeeded .append ((src , dest ))
266- delete_batch = [src for src , dest in copy_succeeded ]
267- delete_statuses = self ._gcsIO ().delete_batch (delete_batch )
268- for i , (src , exception ) in enumerate (delete_statuses ):
269- dest = copy_succeeded [i ][1 ]
270- if exception :
271- exceptions [(src , dest )] = exception
257+ try :
258+ for batch in gcs_batches :
259+ self ._gcsIO ().copy_batch (batch )
260+ self ._gcsIO ().delete_batch (source_file_names )
272261
273- if exceptions :
274- raise BeamIOError ("Rename operation failed" , exceptions )
262+ except Exception as exception :
263+ raise BeamIOError ("Rename operation failed" , exception )
275264
276265 def exists (self , path ):
277266 """Check if the provided path exists on the FileSystem.
@@ -340,8 +329,7 @@ def metadata(self, path):
340329 """
341330 try :
342331 file_metadata = self ._gcsIO ()._status (path )
343- return FileMetadata (
344- path , file_metadata ['size' ], file_metadata ['last_updated' ])
332+ return FileMetadata (path , file_metadata ['size' ], file_metadata ['updated' ])
345333 except Exception as e : # pylint: disable=broad-except
346334 raise BeamIOError ("Metadata operation failed" , {path : e })
347335
@@ -360,12 +348,7 @@ def _delete_path(path):
360348 else :
361349 path_to_use = path
362350 match_result = self .match ([path_to_use ])[0 ]
363- statuses = self ._gcsIO ().delete_batch (
364- [m .path for m in match_result .metadata_list ])
365- # pylint: disable=used-before-assignment
366- failures = [e for (_ , e ) in statuses if e is not None ]
367- if failures :
368- raise failures [0 ]
351+ self ._gcsIO ().delete_batch ([m .path for m in match_result .metadata_list ])
369352
370353 exceptions = {}
371354 for path in paths :
0 commit comments