in src/Script/Composer/Composer.php [75:130]
private static function removeServiceDirs(
$event,
$filesystem,
$serviceMapping,
$listedServices,
$vendorPath
) {
$unsafeForDeletion = ['Kms', 'S3', 'SSO', 'SSOOIDC', 'Sts'];
if (in_array('DynamoDbStreams', $listedServices)) {
$unsafeForDeletion[] = 'DynamoDb';
}
$clientPath = $vendorPath . '/aws/aws-sdk-php/src/';
$modelPath = $clientPath . 'data/';
$deleteCount = 0;
foreach ($serviceMapping as $clientName => $modelName) {
if (!in_array($clientName, $listedServices) &&
!in_array($clientName, $unsafeForDeletion)
) {
$clientDir = $clientPath . $clientName;
$modelDir = $modelPath . $modelName;
if ($filesystem->exists([$clientDir, $modelDir])) {
$attempts = 3;
$delay = 2;
while ($attempts) {
try {
$filesystem->remove([$clientDir, $modelDir]);
$deleteCount++;
break;
} catch (IOException $e) {
$attempts--;
if (!$attempts) {
throw new IOException(
"Removal failed after several attempts. Last error: " . $e->getMessage()
);
} else {
sleep($delay);
$event->getIO()->write(
"Error encountered: " . $e->getMessage() . ". Retrying..."
);
$delay += 2;
}
}
}
}
}
}
$event->getIO()->write(
"Removed $deleteCount AWS service" . ($deleteCount === 1 ? '' : 's')
);
}