Index: src/S3fsService.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/S3fsService.php	(revision 3475ef7e326f5842b74749f44b920378072e2307)
+++ src/S3fsService.php	(revision )
@@ -316,10 +316,17 @@
       $iterator_args['Prefix'] = "{$config['root_folder']}/";
 
     }
-    // Create an iterator that will emit all of the objects matching the
-    // key prefix.
-    $versions = $s3->ListObjectVersions($iterator_args);
-    $v = $versions->get('Versions');
+    $v = [];
+    try {
+      $objects = $s3->getIterator('ListObjectVersions', $iterator_args);
+      foreach ($objects as $object) {
+        $v[] = $object;
+      }
+
+    } catch (S3Exception $e) {
+      echo $e->getMessage() . "\n";
+    }
+
     $iterator = new ArrayIterator($v);
 
     // The $folders array is an associative array keyed by folder paths, which
@@ -402,10 +409,14 @@
       }
     }
 
-    // The event listener doesn't fire after the last page is done, so we have
-    // to write the last page of metadata manually.
-    $this->writeTemporaryMetadata($file_metadata_list, $folders);
+    // We need to split the data into manageable parts for the database.
+    $chunks = array_chunk($file_metadata_list,  '10000');
+    foreach ($chunks as $chunk) {
+      // The event listener doesn't fire after the last page is done, so we have
+      // to write the last page of metadata manually.
+      $this->writeTemporaryMetadata($chunk, $folders);
 
+    }
     // Now that the $folders array contains all the ancestors of every file in
     // the cache, as well as the existing folders from before the refresh,
     // write those folders to the DB.
