[tahoe-dev] Mutable versus immutable uris.

Brian Warner warner at allmydata.com
Thu Oct 18 16:38:43 UTC 2007

> I've begun a fuse proof-of-concept extension which uses the webapi.

Excellent! You might consider an in-node extension, but a FUSE-webapi bridge
offers more flexibility in deployment (and allows the bridge to use a remote
node), so I'm eager to see your results!

> Is it true that file URIs refer to unique, immutable content, whereas
> directory URIs refer to mutable content?  Is there a way to determine
> whether or not the referent of a URI is mutable?  This would obviously
> simplify any caching strategy.

At the moment, all file URIs are immutable, whether they be CHK (the usual
erasure-coded+distributed scheme) or LIT (the-less-than-150bytes
so-just-put-it-in-the-URI scheme), and all directory URIs refer to dirnodes
which are potentially mutable (but not necessarily by you, if you only have a
readonly DIR-RO URI to it).

In the future we plan to add mutable files, and immutable directories (the
"virtual CD" think, where the directory information is stored in a CHK
structure). These are at least a month off, though.

Note that there is a difference between writable (by you) and mutable. CHK
files are immutable: once created, there is nobody in the entire world who
can modify it. Dirnodes are (currently) always mutable, but a given URI may
or may not provide writability to its holder. Immutability implies
un-writeability, but not the other way around.

The best way to determine if a URI refers to a modifyable resource is
in-process (i.e. by importing the 'allmydata' python package), by first
converting the string URI into a URI instance, then asking the instance
is_readonly() and is_mutable(). The conversion is performed by adapting the
string to the IURI interface:

 from allmydata.interfaces import IURI
 u = IURI("URI:CHK:iah546ukk6eqntehth1s3ndeoh:it9o1k5db7mjwjbj3tdd7qjyghf3qjkq7ntjd6ad5e3ufii3uwwo:3:10:35769")
 if u.is_readonly():
   print "I cannot write to this resource."
   print "I can write to this resource."
 if u.is_mutable():
   print "Somebody might be able to write to this resource."
   print "Nobody can write to this resource, because it is immutable."

To accomplish the same thing from outside the node, your best bet is to parse
the prefix of the URI (everything up to the second colon) and drop it into
one of four categories:

 URI:CHK:..    : immutable
 URI:LIT:..    : immutable
 URI:DIR:..    : mutable, writable
 URI:DIR-RO:.. : mutable, not writable

We might be changing the format of these URIs at some point (I know there's
some desire to remove the URI: prefix, for example), and we'll definitly be
adding some types, but this is a good approach for now.

good luck!

More information about the tahoe-dev mailing list