Skip to content

Commit 23105f0

Browse files
committed
Merge pull request #499 from rackspace/working
Merging working -> master in preparation for patch release
2 parents 6583851 + 5228802 commit 23105f0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/OpenCloud/ObjectStore/Resource/Container.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,15 @@ public function delete($deleteObjects = false)
179179

180180
public function deleteWithObjects($secondsToWait = null)
181181
{
182-
// If timeout (seconds to wait) is not specified by caller, try to
183-
// estimate it based on number of objects in container
182+
// If container is empty, just delete it
183+
$numObjects = (int) $this->retrieveMetadata()->getProperty('Object-Count');
184+
if (0 === $numObjects) {
185+
return $this->delete();
186+
}
187+
188+
// If timeout ($secondsToWait) is not specified by caller,
189+
// try to estimate it based on number of objects in container
184190
if (null === $secondsToWait) {
185-
$numObjects = (int) $this->retrieveMetadata()->getProperty('Object-Count');
186191
$secondsToWait = round($numObjects / 2);
187192
}
188193

@@ -205,9 +210,11 @@ public function deleteWithObjects($secondsToWait = null)
205210
}
206211
}
207212
}
213+
208214
if (!$containerDeleted) {
209-
throw new ContainerException('Container and all its objects cound not be deleted');
215+
throw new ContainerException('Container and all its objects could not be deleted.');
210216
}
217+
211218
return $response;
212219
}
213220

0 commit comments

Comments
 (0)