February 02, 2014, 01:27:06 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
   Home   Help Search Login Register  
Pages: [1]
Author Topic: linux/windows filesystem ruby portability  (Read 2413 times)
Jr. Member
Posts: 52

View Profile
« on: March 07, 2007, 06:57:09 AM »

man, timing out while writing a long reply sucks  Cry

it seems to me there are several cases:

1) user attempts to retrieve a file or directory whose stored name is illegal on the local system;  File.new() or FileUtils.mkdir_p raises Errno::EINVAL; I suggest catching it, reporting it with a warning, and continuing (note the directory case may cause a cascade of failures)

2) user attempts to retrieve a file whose type is not supported on the local system (e.g. symlink); File.symlink() raises NotImplementedError; I suggest catch/report/continue, as above

3) user attempts to restore a file when a local object by the same name but wrong type exists; depending how you do the check you might get Errno::EEXIST or you might find out in advance so no exception happens; report and continue

4) user attempts to archive a file that you don't restore correctly, e.g. hardlink;  I suggest noting that it will be copied rather than saved as a link (and if users complain, fine, let them suggest how it could be handled, as we have discussed it isn't a simple problem)

what I don't suggest doing is trying to figure out in advance if a file is going to be illegal or unsupported somewhere else...after all, the file exists on the local machine and that may be the only place the user cares about, and also there is the chance that ruby will support something like symlinks on windows in the future. 

of course if the user tries to archive a file that can't be restored locally that's a different issue.  I only allow ordinary files, symlinks and directories, so if the user tries to archive something like /dev/zero, a socket, a FIFO, etc, I just say "so sorry" and go on.

I use some wrapper classes to hide the differences between various file types so my code to catch these errors is relatively centralized.  the case of files exists locally with wrong type I just check before attempting any restore.


one more thing I didn't attempt is windows ntfs ACLs and SELinux security contexts. see http://www.phptr.com/articles/article.asp?p=606586&rl=1 for a little idea of how deep the swamp is.  my assumption is users sophisticated enough to care about these will use a fancier solution than I could provide, and of course there is the little problem that I don't know if ruby even supports reading/writing the extended attributes involved.
« Last Edit: March 07, 2007, 07:40:59 AM by lowflyinghawk » Logged
Pages: [1]
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!