How can you check to see if a file exists (on the remote server) in Capistrano?

Viewed 23182

Like many others I've seen in the Googleverse, I fell victim to the File.exists? trap, which of course checks your local file system, not the server you are deploying to.

I found one result that used a shell hack like:

if [[ -d #{shared_path}/images ]]; then ...

but that doesn't sit well with me, unless it were wrapped nicely in a Ruby method.

Has anybody solved this elegantly?

5 Answers
Related