Skip to content

Commit c8731b0

Browse files
committed
Improve recursive object restore
When restoring a complete bucket stop and raise an error only when the configuration is set to stop on the first error. otherwise keep trying to restore the next objects. Ignore the following errors: - When the object is currently in transition - When the object is not concerned by the restore request (already in standard storage-class etc) closes #1369 Signed-off-by: Alexandre Lavigne <[email protected]>
1 parent dbdee8f commit c8731b0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

s3cmd

+9-3
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,8 @@ def cmd_object_restore(args):
923923
warning(u"Exiting now because of --dry-run")
924924
return EX_OK
925925

926+
ret = EX_OK
927+
926928
for key in remote_list:
927929
item = remote_list[key]
928930

@@ -932,13 +934,17 @@ def cmd_object_restore(args):
932934
response = s3.object_restore(S3Uri(item['object_uri_str']))
933935
output(u"restore: '%s'" % item['object_uri_str'])
934936
except S3Error as e:
935-
if e.code == "RestoreAlreadyInProgress":
937+
if e.code in ("RestoreAlreadyInProgress", "InvalidObjectState"):
936938
warning("%s: %s" % (e.message, item['object_uri_str']))
937-
else:
939+
elif cfg.stop_on_error:
938940
raise e
941+
else:
942+
error("restore failed for: '%s' (%s)", item['object_uri_str'], e)
943+
ret = EX_PARTIAL
944+
939945
else:
940946
debug(u"Skipping directory since only files may be restored")
941-
return EX_OK
947+
return ret
942948

943949

944950
def subcmd_cp_mv(args, process_fce, action_str, message):

0 commit comments

Comments
 (0)