Pushing Deleted/Renamed File/Directory Changes?

Issue #22 resolved
Amit Goyal created an issue

Hello alixandru!

This works brilliantly except when I push any changes that involve a file or folder being renamed or deleted. The older files/folders are never removed and persist on the server. Do you have any idea as to why this might be happening?

Comments (12)

  1. Alexandru Lixandru repo owner

    Happy new year to you too.

    Have you checked if the user execuring the deploy script (perhaps the web server daemon) has enough permissions to delete files & folders? The script does delete any removed file and folders which remain empty after deployment, so it must be something related to your setup. Also, do enable verbose output in config.php and watch the messages you get at deployment (you might want to trigger the deployment manually and access deploy.php from the browser after the push).

    Alex

  2. Amit Goyal reporter

    Hey Alixandru,

    So I tested the following and I still haven't been able to resolve it.

    [1] Tested the server to check whether the daemon allows PHP scripts to delete files with the following test delete.php script, which worked as expected.

    unlink('/home/d***/public_html/index.html');
    

    [2] Created a test file called test.txt with a single character in it, committed and pushed to the server, file was successfully created. Deleted the file, committed and pushed to the server, files still stayed on the server. This is what I receive when I access deploy.php for a file deletion/file rename.

    http://someurl.com/bitsync/deploy.php?setup=test.git&key=password&team=username

    BitBucket Sync - Full Deploy
    ============================
     * Fetching archive from https://bitbucket.org/username/test.git/get/master.zip
     * Extracting archive to .commits/
     * Copying new content to /home/d***/public_html/
     * Cleaning up temporary files and folders
    
    Finished deploying test.git.
    

    I also tried the above with the retry argument, but I don't see any pending changes in the commits folder, so it didn't change the verbose output.

    We're using the script successfully for 3 repositories now but we have to manually delete any renamed or deleted files, so we'd greatly appreciate any ideas on how to resolve this!

  3. Alexandru Lixandru repo owner

    Let me do some tests with my setups and see if it's working for me. It is possible that BitBucket changed something in the POST hook implementation which broke the script. I will get back to you shortly.

  4. Amit Goyal reporter

    Thanks Alixandru! If you need any more information from my side or the config settings that I used to set my end up, please don't hesitate to ask.

  5. Alexandru Lixandru repo owner

    Oh, I see. You are using a full deploy, not incremental deployment.

    In this case, the only solution available is to clean the destination directory before the full deployment is performed. For example, if your project is deployed to a folder called /home/site/www, you can instruct the script to delete everything inside www folder before the repository content is deployed. This would work fine if you don't have extra files or folders outside your repository which you would like to keep (i.e. if you deploy directly to a 'public_html' folder which most hosting servers provide, cleaning it might not be a good choice as this will wipe everything at deployment). So you need to be careful with this. You can enable cleaning by using the &clean=1 URL parameter.

    Another approach would be to use incremental deployment, with a POST hook defined in on bitbucket.org, which would account for deletions and work smoother due to reduced network traffic (only content of added/changed files is transferred to your server).

    Let me know if you need further clarifications.

    Alex

  6. Amit Goyal reporter

    Okay, that was me testing it out by trying to emulate the gateway.php POST hook by passing the values directly to deploy.php.

    I did setup a POST hook through Bitbucket and pointed it to a domain which was as follows,

    http://someurl.com/bitsync/gateway.php?setup=test.git&key=password&team=username
    

    My config.php file has the repository listed as,

    $DEPLOY = array(
        'test.git' => '/home/d***/public_html/',
    );
    

    Could it be the team variable causing it to use deployment mode instead of incremental mode? The problem is that the bitbucket account does not own the repo, so it gives me an invalid git error if I skip the team variable.

    I think I'm screwing up something really basic.

  7. Alexandru Lixandru repo owner

    I see. Just drop the setup=... part of the URL - in case you have automatic deployment enabled in config.php, it will force a full deployment. Keep key and team parameters if you need them. That should do it.

  8. Alexandru Lixandru repo owner

    Some notes: automaticDeployment should be left disabled until you have everything working fine. In the mean time, trigger the deployment manually by accessing deploy.php with the needed parameters.

  9. Amit Goyal reporter

    Thanks Alixandru! Works as intended. Somehow I thought setup would be required as the config file is capable of handling multiple repositories. Thanks for the help!

    ..not sure if you received my message, can't say how Bitbucket handles messages, but if you do decide to go ahead with building an interface for BB-sync, I'd love to help.

  10. Alexandru Lixandru repo owner

    Yep, I saw your message but didn't get the chance to reply. I did start some planning, together with @apintocr, but until now there was nothing actually implemented. I want to make some changes to the scripts before starting working on the GUI (i.e. #2, but other new features too). However, I didn't find the time to work on this and starting a GUI before these would not be a good idea as the script will change significantly. Unfortunately I don't know when I will be able to start the work on this.

    If you would like to have a look at the plan we have so far, you can check this Trello board: https://trello.com/b/qGHNlvWC

    We'll keep in touch when I will be able to progress with this. Thanks for your help!

  11. Log in to comment