File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
lib/OpenCloud/ObjectStore/Resource Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -179,13 +179,16 @@ 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 = $ this ->getObjectCount ();
184+ if ($ numObjects === 0 ) {
185+ return $ this ->delete ();
186+ }
187+ // If timeout ($secondsToWait) is not specified by caller,
188+ // try to estimate it based on number of objects in container
184189 if (null === $ secondsToWait ) {
185- $ numObjects = (int ) $ this ->retrieveMetadata ()->getProperty ('Object-Count ' );
186190 $ secondsToWait = round ($ numObjects / 2 );
187- }
188-
191+ }
189192 // Attempt to delete all objects and container
190193 $ endTime = time () + $ secondsToWait ;
191194 $ containerDeleted = false ;
@@ -206,7 +209,7 @@ public function deleteWithObjects($secondsToWait = null)
206209 }
207210 }
208211 if (!$ containerDeleted ) {
209- throw new ContainerException ('Container and all its objects cound not be deleted ' );
212+ throw new ContainerException ('Container could not be deleted. ' );
210213 }
211214 return $ response ;
212215 }
You can’t perform that action at this time.
0 commit comments