Skip to content

Commit 5228802

Browse files
author
Jamie Hannaford
committed
Merge pull request #498 from ycombinator/pr490-tweaks
Tweaks to PR 490
2 parents 0888361 + 01f9173 commit 5228802

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/OpenCloud/ObjectStore/Resource/Container.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,17 @@ public function delete($deleteObjects = false)
180180
public function deleteWithObjects($secondsToWait = null)
181181
{
182182
// If container is empty, just delete it
183-
$numObjects = $this->getObjectCount();
184-
if ($numObjects === 0) {
183+
$numObjects = (int) $this->retrieveMetadata()->getProperty('Object-Count');
184+
if (0 === $numObjects) {
185185
return $this->delete();
186186
}
187+
187188
// If timeout ($secondsToWait) is not specified by caller,
188189
// try to estimate it based on number of objects in container
189190
if (null === $secondsToWait) {
190191
$secondsToWait = round($numObjects / 2);
191-
}
192+
}
193+
192194
// Attempt to delete all objects and container
193195
$endTime = time() + $secondsToWait;
194196
$containerDeleted = false;
@@ -208,9 +210,11 @@ public function deleteWithObjects($secondsToWait = null)
208210
}
209211
}
210212
}
213+
211214
if (!$containerDeleted) {
212-
throw new ContainerException('Container could not be deleted.');
215+
throw new ContainerException('Container and all its objects could not be deleted.');
213216
}
217+
214218
return $response;
215219
}
216220

0 commit comments

Comments
 (0)