]> git.donarmstrong.com Git - bin.git/commitdiff
* retry when there is a failure
authorDon Armstrong <don@donarmstrong.com>
Mon, 15 Aug 2011 04:37:15 +0000 (04:37 +0000)
committerDon Armstrong <don@donarmstrong.com>
Mon, 15 Aug 2011 04:37:15 +0000 (04:37 +0000)
fb_upload

index f46e87d586fe9c0cc5e0b708fb3288be789bca63..b33a84eab086460a06a2a4d38aaecadc678fbe6f 100755 (executable)
--- a/fb_upload
+++ b/fb_upload
@@ -140,12 +140,19 @@ else {
 
 for my $photo (@photos) {
     print "Uploading $photo";
-    my $response =
-       $client->photos->upload(aid => $aid,
-                               data => scalar read_file($photo),
-                               caption => '',
-                               filename => basename($photo),
-                              );
+    my $response;
+    my $try=0;
+    while (not $response =
+          $client->photos->upload(aid => $aid,
+                                  data => scalar read_file($photo),
+                                  caption => '',
+                                  filename => basename($photo),
+                                 )) {
+       $try++;
+       print " [failure $try] ";
+       sleep 3;
+       last if $try > 10;
+    }
     if (not $response) {
        die "Upload failure at photo $photo";
     }