Ruby Fileutils.cp_r Permission Denied when :preserve => true
I am trying to implement a poor-man's backup/mirroring script and am having some trouble.
I am on Windows-XP, using Ruby's FileUtils module to recursively copy files.
So long as I don't set the :preserve flag to true, everything works fine.
Works:
FileUtils.cp_r('Source_dir', 'Dest_dir', :verbose => true)
Doesn't work:
FileUtils.cp_r('Source_dir', 'Dest_dir', :verbose => true, :preserve开发者_高级运维 => true)
I have full permissions on the Dest_dir as it's on the desktop of my local machine and I just created it. I can copy and delete files and folders, but apparently changing, or maintaining the file attributes with :preserve isn't working. I haven't had a chance to try this on a Mac or linux box, but from reading around online the :preserve flag is a normal stumbling block to come up against in a Windows environment.
In a similar line of questioning, what is the default behavior for FileUtils.cp_r when it encounters an existing file at the destination directory? Simply overwrite and replace everything in Destination with whatever is in Source, or can I skip a file with conflicts and just log it for resolution later? (If this should be a separate question, just let me know and I'll make it one.)
Thanks,
Spencer
I ended up having to change the permissions on the target directory to allow modify, as it appears it writes the file and then modifies the attributes.
精彩评论