File tree 1 file changed +11
-4
lines changed
lib/OpenCloud/ObjectStore/Resource
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -179,10 +179,15 @@ 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 = (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
184
190
if (null === $ secondsToWait ) {
185
- $ numObjects = (int ) $ this ->retrieveMetadata ()->getProperty ('Object-Count ' );
186
191
$ secondsToWait = round ($ numObjects / 2 );
187
192
}
188
193
@@ -205,9 +210,11 @@ public function deleteWithObjects($secondsToWait = null)
205
210
}
206
211
}
207
212
}
213
+
208
214
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. ' );
210
216
}
217
+
211
218
return $ response ;
212
219
}
213
220
You can’t perform that action at this time.
0 commit comments