index.js
function attemptCallback(filePath, callback, attempts) {

	try {

		callback();
		return;

	} catch (error) {

		if (attempts === 0) {
			console.error('takeown: callback failed - exceeded attempts');
			throw error;
		}

		switch (error.code) {

			case 'EPERM':
			case 'EACCES':
			case 'EBUSY':
			case 'ENOTEMPTY':
				return attemptCallback(filePath, callback, --attempts);

			default:
				throw error;
		}
	}
}
function attemptCallback(filePath, callback, attempts) {

	try {

		callback();
		return;

	} catch (error) {

		if (attempts === 0) {
			console.error('takeown: callback failed - exceeded attempts');
			throw error;
		}

		switch (error.code) {

			case 'EPERM':
			case 'EACCES':
			case 'EBUSY':
			case 'ENOTEMPTY':
				return attemptCallback(filePath, callback, --attempts);

			default:
				throw error;
		}
	}
}
function attemptCallback ( filePath , callback , attempts ) { try { callback ( ) ; return ; } catch ( error ) { if ( attempts === 0 ) { console . error ( 'takeown: callback failed - exceeded attempts' ) ; throw error ; } switch ( error . code ) { case 'EPERM' : case 'EACCES' : case 'EBUSY' : case 'ENOTEMPTY' : return attemptCallback ( filePath , callback , -- attempts ) ; default : throw error ; } } }
Intentionally locks up javascript thread for a fixed number of recursive calls to give Windows time to get its arse in gear.
Intentionally locks up javascript thread for a fixed number of recursive calls to give Windows time to get its arse in gear .