Phing - Deploy with FTP but only overwrite when size has changed
Asked Answered
P

5

5

I am using Phing and right now I am using this code to upload my files to FTP:

<target name="ftp.upload">
    <echo>Uploading files to FTP</echo>
    <ftpdeploy 
        host="${ftp.destination.host}"
        port="${ftp.destination.port}"
        username="${ftp.destination.username}"
        password="${ftp.destination.password}"
        dir="${ftp.destination.dir}"
        mode="${ftp.destination.mode}">
       <fileset refid="TheFiles" />
    </ftpdeploy>
    <echo>FTP Upload Finished!</echo>
</target>

It takes a long time to load, and I have a lot of images - so every time I make a small text change, I don't want it to re-upload everything. Is there a way to detect which files has been changed and only upload those?

Thanks!

Popovich answered 11/10, 2011 at 15:5 Comment(0)
D
9

This is a little late ... but you CAN actually do this with Phing. This requires a few steps:

Define a date property to go off from. This will be necessary at the end when you're saving last build date for future builds

< tstamp>
  < format property="builddate" pattern="%m/%d/%Y"  />
  < format property="buildtime" pattern="%I:%M %p" />
< /tstamp>

Define lastbuilddate property. Define it to something way back. Then include a file (will be created at the end of your run) with the same property. If file exists (2nd run and after), it will override the setting you defined with whatever the last date was

< property name="lastbuilddate" value="01/01/1970 12:00 AM" />
< property file="$.\lastbuild.properties" override="true"/>

Include date task in your fileset definition. That specifies to only pick files that have last modified date AFTER your last build date

< fileset id="TheFiles" > < date datetime="${lastbuilddate}" when="after"/> < / fileset>

Run your ftp for the TheFiles fileset

Update the lastbuild.properties file with the latest run date. Noticed that we're using date/time properties defined initially.

    < echo msg="lastbuilddate=${builddate} ${buildtime}" file="$./lastbuild.properties" append="false" />

Every time you run your target, it will only ftp files that were changed since the date specified in lastbuilddate property

Don answered 9/9, 2012 at 20:33 Comment(0)
M
2

I'm afraid there's no way to achieve this using FTP unless YOU maintain some kind of list of modified files. So you'd be better off using rsync. There's a solution already available for phing: http://blog.fedecarg.com/2008/07/21/filesynctask-using-phing-to-synchronize-files-and-directories/

Mouse answered 12/10, 2011 at 9:24 Comment(0)
F
0

I wrote down a perl script that does it with a svn repository ( http://svnftpdeploy.sourceforge.net/ ... I do not know what I wrote in english)

It requires a local directory to get files from svn, another to to get files from ftp (the changed in the next svn release), a local file for store last uploaded svn release, a local directory to store changed file list from ftp. And it interactively ask for action in case of conflict (someone changed file in server independently from your deploy script).

Now I am switching to phing and git, the hard part would be to manage interactivity, I think I would manage it with -D= for the target deploy (with -Dconflictaction=stop,viewdiff,viewdiffanddeploy,ignore or such a thing).

Fed answered 22/8, 2012 at 10:3 Comment(0)
M
0

You can use git-ftp or dandelion to upload just the changes via ftp. I guess it is not so hard to use one of them with phing...

Mesarch answered 2/5, 2014 at 3:53 Comment(0)
F
0

Have you tried using the depends="true" attribute of FtpDeployTask?

If depends is set to true, the task will only update files with a local modification timestamp that is newer than the corresponding timestamp on the server.

Sadly, this doesn't seem to work for me: all files are being transferred.

Flaxman answered 19/8, 2014 at 12:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.