It was taking a long time to upload our deployments using the update
strategy. We moved to using the copy strategy with a .tar.bz2 and that
improved things, but I noticed it was including all the .svn
directories in the tarball. Given that we aren't going to use 'svn up'
remotely because we're using the copy strategy, I decided I could do
without them. So I redefined
Capistrano::Deploy::Strategy::Copy#deploy! in such a way that it
removed all the .svn files before compressing and sending the file
(see below). This brought the file size of the .tar.bz2 file down from
5 MB to 3 MB, which saves us a bit of time and bandwidth during
deployments.

Would it be possible to add a hook or an option to this function so I
don't have to override it in this way?

---

require 'capistrano/recipes/deploy/strategy/copy'

# Redefine this so that we can remove .svn cruft before compressing,
to save us
# some bandwidth.
Capistrano::Deploy::Strategy::Copy.class_eval do
  def deploy!
    logger.debug "getting (via #{copy_strategy}) revision #{revision}
to #{destination}"
    system(command)
    File.open(File.join(destination, "REVISION"), "w") { |f|
f.puts(revision) }

    # Remove svn cruft before compressing! It saves us megabytes! We
won't be
    # using 'svn up' if we're using the copy strategy anyway so we
don't need
    # all this junk.
    FileUtils.rm_rf(Dir.glob(File.join(destination,
"**/.svn")), :verbose => true)

    logger.trace "compressing #{destination} to #{filename}"
    Dir.chdir(tmpdir) { system(compress(File.basename(destination),
File.basename(filename)).join(" ")) }

    content = File.open(filename, "rb") { |f| f.read }
    put content, remote_filename
    run "cd #{configuration[:releases_path]} &&
#{decompress(remote_filename).join(" ")} && rm #{remote_filename}"
  ensure
    FileUtils.rm filename rescue nil
    FileUtils.rm_rf destination rescue nil
  end
end

--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to