File tree 1 file changed +9
-6
lines changed
lib/OpenCloud/ObjectStore/Resource 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)
179
179
180
180
public function deleteWithObjects ($ secondsToWait = null )
181
181
{
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
184
189
if (null === $ secondsToWait ) {
185
- $ numObjects = (int ) $ this ->retrieveMetadata ()->getProperty ('Object-Count ' );
186
190
$ secondsToWait = round ($ numObjects / 2 );
187
- }
188
-
191
+ }
189
192
// Attempt to delete all objects and container
190
193
$ endTime = time () + $ secondsToWait ;
191
194
$ containerDeleted = false ;
@@ -206,7 +209,7 @@ public function deleteWithObjects($secondsToWait = null)
206
209
}
207
210
}
208
211
if (!$ containerDeleted ) {
209
- throw new ContainerException ('Container and all its objects cound not be deleted ' );
212
+ throw new ContainerException ('Container could not be deleted. ' );
210
213
}
211
214
return $ response ;
212
215
}
You can’t perform that action at this time.
0 commit comments