GNOME Bugzilla – Bug 620423
Document the possibility to unset attributes
Last modified: 2011-07-19 20:56:12 UTC
Document that attributes can be unset by passing the special "unset" type to gvfs-set-attribute Appearantly, in gio attributes are unset by passing NULL as the attribute value. I am not sure about that, but if that's correct, this behaviour should be documented as well.
Created attachment 162596 [details] [review] Document the possibility to unset attributes in gvfs-set-attribute
Created attachment 162597 [details] [review] Document that setting an attribute value of a GFile to NULL unsets the attribute
Review of attachment 162596 [details] [review]: Looks right.
Review of attachment 162597 [details] [review]: I don't think that is true. If you look at _g_file_attribute_value_set_from_pointer, you really ought to pass G_FILE_ATTRIBUTE_TYPE_INVALID for that. But looking at g_file_set_attribute, that won't really work either.
You're right with G_FILE_ATTRIBUTE_TYPE_INVALID. That's exactly how gvfs-set-attribute works for unset: Setting the type to G_FILE_ATTRIBUTE_TYPE_INVALID and the value to NULL.
Can I commit this patch then?
Created attachment 189470 [details] [review] Document how to unset an attribute in GIO. The patch concerning gvfs-set-attribute is obsolete, as it has already been taken care of in http://git.gnome.org/browse/gvfs/commit/?id=e6b6ecf80e5db77a6cfb087cacde4cb1a277def0 In my understanding this is also what gvfs-set-attribute does to unset an attribute. I'm not sure what Matthias meant with " But looking at g_file_set_attribute, that won't really work either."
(In reply to comment #5) > You're right with G_FILE_ATTRIBUTE_TYPE_INVALID. That's exactly how > gvfs-set-attribute works for unset: Setting the type to > G_FILE_ATTRIBUTE_TYPE_INVALID and the value to NULL. Can you give me an example how one can use gvfs-set-attribute to unset an attribute ? My attempts have failed like > gvfs-set-attribute -t unset ./test.py selinux::context Error setting attribute: Invalid attribute type (byte string expected)
(In reply to comment #8) > Can you give me an example how one can use gvfs-set-attribute to unset an > attribute ? For me, unsetting attributes on files or directories works as you described. I can e.g. attach a note to a file with Nautilus, and then remove this note with > gvfs-set-attribute -t unset ./test.py metadata::annotation If I try with an attribute that I shouldn't be able to set/unset, I get > gvfs-set-attribute -t unset ./test.py unix::blocks Error setting attribute: Setting attribute unix::blocks not supported I'm not using selinux, so I can't check your example. I'll try to ping somebody with more insight. It would be nice to have this cleared up.
This only works for the metadata attributes at the moment. I think we should make the docs a bit more vague saying that some fields can be unset this way. There is no way to unset most attributes (like inode or mtime) anyway. We should probably add support for xattr unset though, and it would use the same "API".
Created attachment 191849 [details] [review] Document how to unset attributes Thanks for the insight, Alex. Personally, I'm already happy if I know how I can unset metadata attributes that I set myself, in order to be able to clean up after myself. I attached a patch with a very vague description, and from my side we could be done and close the bug.
Review of attachment 191849 [details] [review]: Looks fine to me.
Attachment 191849 [details] pushed as d1e5161 - Document how to unset attributes