@@ -184,7 +184,7 @@ function rimrafSync(path, options) {
184
184
if ( stats !== undefined && stats . isDirectory ( ) )
185
185
_rmdirSync ( path , options , null ) ;
186
186
else
187
- unlinkSync ( path ) ;
187
+ _unlinkSync ( path , options ) ;
188
188
} catch ( err ) {
189
189
if ( err . code === 'ENOENT' )
190
190
return ;
@@ -198,6 +198,25 @@ function rimrafSync(path, options) {
198
198
}
199
199
200
200
201
+ function _unlinkSync ( path , options ) {
202
+ const tries = options . maxRetries + 1 ;
203
+
204
+ for ( let i = 1 ; i <= tries ; i ++ ) {
205
+ try {
206
+ return unlinkSync ( path ) ;
207
+ } catch ( err ) {
208
+ // Only sleep if this is not the last try, and the delay is greater
209
+ // than zero, and an error was encountered that warrants a retry.
210
+ if ( retryErrorCodes . has ( err . code ) &&
211
+ i < tries &&
212
+ options . retryDelay > 0 ) {
213
+ sleep ( i * options . retryDelay ) ;
214
+ }
215
+ }
216
+ }
217
+ }
218
+
219
+
201
220
function _rmdirSync ( path , options , originalErr ) {
202
221
try {
203
222
rmdirSync ( path ) ;
@@ -264,7 +283,7 @@ function fixWinEPERMSync(path, options, originalErr) {
264
283
if ( stats . isDirectory ( ) )
265
284
_rmdirSync ( path , options , originalErr ) ;
266
285
else
267
- unlinkSync ( path ) ;
286
+ _unlinkSync ( path , options ) ;
268
287
}
269
288
270
289
0 commit comments