File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,7 +156,22 @@ protected function sqlite_drop() {
156156 unset( $ wpdb );
157157 gc_collect_cycles ();
158158
159- if ( ! unlink ( $ db_path ) ) {
159+ $ attempts = 0 ;
160+ $ unlinked = false ;
161+ while ( $ attempts < 10 ) {
162+ if ( ! file_exists ( $ db_path ) ) {
163+ $ unlinked = true ;
164+ break ;
165+ }
166+ if ( @unlink ( $ db_path ) ) {
167+ $ unlinked = true ;
168+ break ;
169+ }
170+ ++$ attempts ;
171+ usleep ( 100000 ); // 100ms
172+ }
173+
174+ if ( ! $ unlinked ) {
160175 WP_CLI ::error ( "Could not delete database file: {$ db_path }" );
161176 }
162177
@@ -182,7 +197,22 @@ protected function sqlite_reset() {
182197 unset( $ wpdb );
183198 gc_collect_cycles ();
184199
185- if ( ! unlink ( $ db_path ) ) {
200+ $ attempts = 0 ;
201+ $ unlinked = false ;
202+ while ( $ attempts < 10 ) {
203+ if ( ! file_exists ( $ db_path ) ) {
204+ $ unlinked = true ;
205+ break ;
206+ }
207+ if ( @unlink ( $ db_path ) ) {
208+ $ unlinked = true ;
209+ break ;
210+ }
211+ ++$ attempts ;
212+ usleep ( 100000 ); // 100ms
213+ }
214+
215+ if ( ! $ unlinked ) {
186216 WP_CLI ::error ( "Could not delete database file: {$ db_path }" );
187217 }
188218 }
You can’t perform that action at this time.
0 commit comments