&clean=1 deletes bitbucket-sync directory

Issue #4 resolved
none none created an issue

Attempted to use deploy.php?setup=my-project-name&clean=1 and it deleted both the project's contents and all the bitbucket-sync directory.

Due to the bitbucket-sync files themselves being deleted the script was then unable to deploy a fresh version of the project.

I could of just been unlucky but I'd of assumed the expected behaviour would be to remove just the old project files before deploying a fresh copy of the project?

Comments (3)

  1. Alexandru Lixandru repo owner

    Well, the logic of this was to delete all the files and directories from within the deployFolder (but not the deployFolder itself). If bitbucket-sync directory and scripts are inside deployFolder then it will get deleted as well.

    The way I see it, there are 2 options:

    • keep the clean process the way it is now, but perform an additional check to make sure 'bitbucket-sync' folder is never deleted by accident
    • change the clean process so that it deletes the contents of deployFolder item by item, by reading what's in the zip archive and deleting only those files and folders which are to be copied afterwards, leaving untouched whatever it cannot see in the zip archive. Need to think of the implications of this.

    Waiting for your thoughts on this.

    Thanks, Alex

  2. none none reporter

    Hi Alex,

    To date the way I have been using the script is just to create a bitbucket-sync directory in the root of each website i am deploying to. While i could set up one master script for multiple websites I find having one script for each website keeps things nice and simple.

    IMO the first option sounds most useful as it's a handy feature be able to clean the deploy directory completely (well, minus the script!)

    The second option sounds to me suspiciously like what your script already does normally - ie: it overwrites any files already present with newer versions of those same files.

    I'm sure i'm missing something but what separates the functionality of &clean=1 for me is that it nukes the entire directory (including any files added since) and then re-deploys from scratch.

    On a separate note I also think it may be worth consideration to decide whether the script is only able to clean the directory if an authkey has been set.

    As far as i'm aware &clean=1 is the one (only?) option that presents a danger. A stranger could run it and nuke any files created in the course of the websites normal operation that are not part of the bitbucket repository.

    If i'm correct the the behaviour of deploy.php is otherwise relatively benign since all it attempts to do is fetch any changes that have been committed to bitbucket since the last time deploy was called. I expect that in 99% of scenarios the website already mirrors the latest commit and so any call to deploy.php would fail harmlessly.

  3. Alexandru Lixandru repo owner

    The last commit introduces 2 changes:

    1. the deploy key is required whenever requesting a full sync with clean up
    2. the current folder executing the deploy code will be excluded from the cleanup process

    Hopefully this will prevent some unpleasant situations.

    Thanks @bit32 for suggestions!

  4. Log in to comment