guard-rsync icon indicating copy to clipboard operation
guard-rsync copied to clipboard

Stripping trailing slashes is breaking RSync

Open chriskempson opened this issue 13 years ago • 5 comments

I'm having to do :input => 'www//' to bypass the @input = ensure_no_trailing_slash(options[:input]) code.

chriskempson avatar Mar 22 '12 12:03 chriskempson

This is to ensure consistent behavior with delete (depends on recursing into a directory) and ignore paths (which have the directory when there is no trailing slash). With the trailing slash rsync isn't syncing the directory, just the files in the directory.

The ignore path code makes an assumption you are recursing into the top directory.

Can you explain a little more about your use case?

krisselden avatar Mar 22 '12 16:03 krisselden

Sure. I'm being forced to work on a samba share for some web dev. I'm using guard-rsync to avoid the shares. My Guardfile looks like this:

guard('rsync', {
  :input => 'www//',
  :output => 'user@server:/var/www/website',
  :excludes => {
    /(.+)\.(php|html|css|js)$/ => ()
  }
}) do
  watch(%r{^www/(.+)\.(php|html|css|js)$})
end

Not sure if the guard file is correct sorry, found the excludes a little confusing if I'm honest but seems to be working.

chriskempson avatar Mar 23 '12 16:03 chriskempson

In the example I gave, excludes was to ignore auto generated files and their sources in the sync. I don't think you actually want any exclude option. The arguments I choose was because I wanted to mirror a directory. That's why it uses -av --delete and no trailing slash (--delete doesn't work outside of directory recursion, so trailing slash would cause it not to work in the top level).

I think what you want is just to be able to run a shell task per batch of changes. Maybe you should request that of guard-shell to have an option to run once per batch rather than a shell per change, because you have a specific rsync command and are not using any of the other options.

krisselden avatar Mar 23 '12 18:03 krisselden

Would it not be better to make guard-rsync more generic so it can be used for many kinds of rsync scenarios? It seems like it was written for a specific rsync scenario only.

chriskempson avatar Mar 25 '12 14:03 chriskempson

I don't know when I'm going to have time to address these, I'd like to make excludes optional, and make the trailing slash just a warning if you combine it with --delete and give a chance to override options before the command is executed.

I am responsive to pull requests.

krisselden avatar Mar 30 '12 06:03 krisselden