@@ -190,7 +190,7 @@ function rimrafSync(path, options) {
190
190
if ( stats !== undefined && stats . isDirectory ( ) )
191
191
_rmdirSync ( path , options , null ) ;
192
192
else
193
- unlinkSync ( path ) ;
193
+ _unlinkSync ( path , options ) ;
194
194
} catch ( err ) {
195
195
if ( err . code === 'ENOENT' )
196
196
return ;
@@ -204,6 +204,25 @@ function rimrafSync(path, options) {
204
204
}
205
205
206
206
207
+ function _unlinkSync ( path , options ) {
208
+ const tries = options . maxRetries + 1 ;
209
+
210
+ for ( let i = 1 ; i <= tries ; i ++ ) {
211
+ try {
212
+ return unlinkSync ( path ) ;
213
+ } catch ( err ) {
214
+ // Only sleep if this is not the last try, and the delay is greater
215
+ // than zero, and an error was encountered that warrants a retry.
216
+ if ( retryErrorCodes . has ( err . code ) &&
217
+ i < tries &&
218
+ options . retryDelay > 0 ) {
219
+ sleep ( i * options . retryDelay ) ;
220
+ }
221
+ }
222
+ }
223
+ }
224
+
225
+
207
226
function _rmdirSync ( path , options , originalErr ) {
208
227
try {
209
228
rmdirSync ( path ) ;
@@ -270,7 +289,7 @@ function fixWinEPERMSync(path, options, originalErr) {
270
289
if ( stats . isDirectory ( ) )
271
290
_rmdirSync ( path , options , originalErr ) ;
272
291
else
273
- unlinkSync ( path ) ;
292
+ _unlinkSync ( path , options ) ;
274
293
}
275
294
276
295
0 commit comments