mass_copy_between_backends: Also catch unexpected exceptions, and simply move on to the next file.
This commit is contained in:
parent
eb7b875122
commit
634b233685
@ -423,18 +423,24 @@ def mass_copy_between_backends(src_backend='cdnsun', dest_backend='gcs'):
|
|||||||
projection={'_id': True})
|
projection={'_id': True})
|
||||||
copied_ok = 0
|
copied_ok = 0
|
||||||
copy_errs = 0
|
copy_errs = 0
|
||||||
for fdoc in fdocs:
|
try:
|
||||||
try:
|
for fdoc in fdocs:
|
||||||
moving.change_file_storage_backend(fdoc['_id'], dest_backend)
|
try:
|
||||||
except moving.PrerequisiteNotMetError as ex:
|
moving.change_file_storage_backend(fdoc['_id'], dest_backend)
|
||||||
log.error('Error copying %s: %s', fdoc['_id'], ex)
|
except moving.PrerequisiteNotMetError as ex:
|
||||||
copy_errs += 1
|
log.error('Error copying %s: %s', fdoc['_id'], ex)
|
||||||
except requests.exceptions.HTTPError as ex:
|
copy_errs += 1
|
||||||
log.error('Error copying %s (%s): %s',
|
except requests.exceptions.HTTPError as ex:
|
||||||
fdoc['_id'], ex.response.url, ex)
|
log.error('Error copying %s (%s): %s',
|
||||||
copy_errs += 1
|
fdoc['_id'], ex.response.url, ex)
|
||||||
else:
|
copy_errs += 1
|
||||||
copied_ok += 1
|
except Exception:
|
||||||
|
log.exception('Unexpected exception handling file %s', fdoc['_id'])
|
||||||
|
copy_errs += 1
|
||||||
|
else:
|
||||||
|
copied_ok += 1
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
log.error('Stopping due to keyboard interrupt')
|
||||||
|
|
||||||
log.info('%i files copied ok', copied_ok)
|
log.info('%i files copied ok', copied_ok)
|
||||||
log.info('%i files we did not copy', copy_errs)
|
log.info('%i files we did not copy', copy_errs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user