18 June 2011

Fishier Still: rm, extra perms and more with fish 3.01

I’ve written a bit about the changes I’ve made to fdb as it became fish. I wanted to test it a bit more myself before pushing it to GitHub, but have now done so as well as making some more changes.

Key things to know:

  • fish 3.0 is simply a renamed version of fdb, reflecting the change in FluidDB’s name to Fluidinfo. It’s available from https://github.com/njr0/fish.
  • I haven’t changed the names of things like the credentials file (though its default position has moved to c:\fish\credentials.txt on Windows, as I said it would). I also haven’t changed the name of the FluidDB class internally, though many other internal names have changed to fish.
  • There are a few commands available in fish 3.01. The most significant changes are the addition of an rm command for removing tags and namespaces, and extensions to the perms command to allow more detailed control if required. (In fact, I believe all possible permissions can now be set with it.)
  • There are some new minor commands as well—touch and mkns/mkdir.
  • I’ve changed the error handling a bit, which should improve things, at least for some kinds of errors.
  • In a minor change, I’ve decided to allow -R and -r to be used interchangably to specify recursive descent. At the moment, that means that ls -r and rm -R will work as well as the more conventional ls -R and rm -r. In future, perms and a planned cp will probably support these options too. Even though, Unix users tend to know which is which, there seems no reason to insis that the “right” one be used in fdb.
  • The documentation is in a new (but even more natural) place in Fluidinfo — http://fluiddb.fluidinfo.com/about/fish/fish/index.html.
  • I haven’t removed fdb from GitHub. It’s more stable and the rename is a pain, o I’ll probably leave it there for 6–12 months before pointing it to fish, which is a new project. Fish is at http://github.com/njr0/fish.

The new features are all documented in the online documentation, but I’ll outline most fo the changes here as well, except for the extended perms options functionality, which I’ll cover in a separate post about how I used them to “secure* the fish user for use with the online version of fish—shell-fish.

rm

The most significant new command is rm. If you’re familiar with Unix, you’ll feel right at home, though there’s no globbing (wildcarding) yet. The rm command can be used to remove one or more empty namespaces or unused tags simply by giving the paths or paths. For example, given a tag njr/rating and a namespace private, the following work:

$ rm njr/rating
$ rm njr/private
$ rm njr/rating njr/private

If you want to remove a non-empty namespace, use -r to do a recursive removal. This will delete all the tags (removing them from objects in the process) and sub-namespaces before removing the nominated namespaces itself:

$ rm -r njr/private

If I followed the Unix analogy slavishly, fish would let you remove a tag even if it were in use (after all, files don’t have to be empty to delete them); however, the potential scale of inadvertant destruction of information is, in our case, large enough that I feel some proection is in order. So to remove a tag that’s in use, fish requires use of either the -r (recurse) or -f (force) flag.

As on Unix, -f is intended to encourage fish just to get on and remove things if humanly (fishily?) possible, and not to complain if the things you’re asking it to remove don’t exist. In time, this will extend to changing permissions, where possible, but right now if you don’t have the relevant permissions removal will fail.

There is no rmns or rmdir command, but fish will suggest you use rm if you find yourself typing them inadvertantly. (I never understood why you can’t remove an empty direcory with a plain rm on Unix anyway.)

touch, mkns and mkdir

Although the Fluidinfo API requires tags to be created before they are used, fish (like its predecessor fdb) has always created tags on first use, including required namespaces, but there are still a couple of situations in which you might want to create them explicitly. One is if you want to pre-permissions; the other is that you might wish to specify the description that both tags and namespaces can have. The relevant commands are:

$ touch user/tag
$ mkns user/ns
$ touch -m "tag description" user/ns/tag
$ mkns -m "namespace description" user/ns1/ns2

The first creates a tag called tag in user‘s namespace, the second creates a namespace ns in user‘s namespace, the third creates a tag called ns/tag in user‘s user/ns namespace, creating user/ns if required, and setting the description (metadata) to “tag description”, and the last does something similar for a namespace user/ns1/ns2.

No comments:

Post a Comment

Labels