Github user dmitriy-barkalov commented on a diff in the pull request:

    https://github.com/apache/cordova-medic/pull/40#discussion_r27984199
  
    --- Diff: buildbot-conf/cordova.conf ---
    @@ -229,6 +229,8 @@ plugins_cleanup_steps = [
         NPMInstall(command=['shelljs'], what='shelljs'),
         RMRF('~/.cordova/*', description='removing cache', 
haltOnFailure=False),
         RMRF(BASE_WORKDIR + '/*', description='cleaning workspace', 
haltOnFailure=False),
    +    RMRF(BASE_WORKDIR + '/*', description='cleaning workspace again', 
haltOnFailure=False),
    +    RMRF(BASE_WORKDIR + '/*', description='cleaning workspace yet again', 
haltOnFailure=True),
    --- End diff --
    
    Here we have good deletion of workspace folder only but `~/.cordova/*` also 
could have the same issues. Also 2 extra steps in builder will confuse a user.
    
    I propose to move this workaround into `RMRF` function. This way there 
would be a clean deletion of any folder. I've made a quick test of deletion js 
script. I hope it will help to illustrate my idea:
    ```
    def RMRF(path, description=None, **kwargs):
    
        if description is None:
            description = 'removing ' + path
    
        # this is better than 'rm -rf' because it removes excessively long 
paths on Windows
        js_script = "var s = require('shelljs'); fs = require('fs'); path = 
require('path'); var attempts = 1, dir = 
path.dirname(path.normalize('{path}')); while((fs.readdirSync(dir).length > 0) 
&& (attempts <= 10)) {{ console.log('removing {path} attempt ' + attempts); 
s.rm('-rf', '{path}'); attempts++; }} process.once('exit', function () {{ if 
(fs.readdirSync(dir).length > 0) {{ process.exit(1); }} }});".format(path=path)
    
        return SH(command=['node', '-e', js_script], description=description, 
**kwargs)
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to