Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/OpenCloud/ObjectStore/Resource/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,16 @@ public function delete($deleteObjects = false)

public function deleteWithObjects($secondsToWait = null)
{
// If timeout (seconds to wait) is not specified by caller, try to
// estimate it based on number of objects in container
// If container is empty, just delete it
$numObjects = $this->getObjectCount();
if ($numObjects === 0) {
return $this->delete();
}
// If timeout ($secondsToWait) is not specified by caller,
// try to estimate it based on number of objects in container
if (null === $secondsToWait) {
$numObjects = (int) $this->retrieveMetadata()->getProperty('Object-Count');
$secondsToWait = round($numObjects / 2);
}

}
// Attempt to delete all objects and container
$endTime = time() + $secondsToWait;
$containerDeleted = false;
Expand All @@ -206,7 +209,7 @@ public function deleteWithObjects($secondsToWait = null)
}
}
if (!$containerDeleted) {
throw new ContainerException('Container and all its objects cound not be deleted');
throw new ContainerException('Container could not be deleted.');
}
return $response;
}
Expand Down