After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620423 - Document the possibility to unset attributes
Document the possibility to unset attributes
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: docs
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-06-03 01:18 UTC by Holger Berndt
Modified: 2011-07-19 20:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Document the possibility to unset attributes in gvfs-set-attribute (1.10 KB, patch)
2010-06-03 01:18 UTC, Holger Berndt
rejected Details | Review
Document that setting an attribute value of a GFile to NULL unsets the attribute (1.01 KB, patch)
2010-06-03 01:23 UTC, Holger Berndt
rejected Details | Review
Document how to unset an attribute in GIO. (888 bytes, patch)
2011-06-08 13:55 UTC, Holger Berndt
none Details | Review
Document how to unset attributes (991 bytes, patch)
2011-07-12 21:25 UTC, Holger Berndt
committed Details | Review

Description Holger Berndt 2010-06-03 01:18:07 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.
Comment 1 Holger Berndt 2010-06-03 01:18:09 UTC
Created attachment 162596 [details] [review]
Document the possibility to unset attributes in gvfs-set-attribute
Comment 2 Holger Berndt 2010-06-03 01:23:49 UTC
Created attachment 162597 [details] [review]
Document that setting an attribute value of a GFile to NULL unsets the attribute
Comment 3 Matthias Clasen 2010-07-09 14:02:39 UTC
Review of attachment 162596 [details] [review]:

Looks right.
Comment 4 Matthias Clasen 2010-07-09 14:13:08 UTC
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.
Comment 5 Holger Berndt 2010-07-09 14:23:14 UTC
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.
Comment 6 Kjartan Maraas 2011-05-24 08:40:43 UTC
Can I commit this patch then?
Comment 7 Holger Berndt 2011-06-08 13:55:34 UTC
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."
Comment 8 Matthias Clasen 2011-06-13 03:13:10 UTC
(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)
Comment 9 Holger Berndt 2011-06-16 17:10:19 UTC
(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.
Comment 10 Alexander Larsson 2011-06-17 09:14:22 UTC
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".
Comment 11 Holger Berndt 2011-07-12 21:25:57 UTC
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.
Comment 12 Matthias Clasen 2011-07-18 23:49:27 UTC
Review of attachment 191849 [details] [review]:

Looks fine to me.
Comment 13 Holger Berndt 2011-07-19 20:56:08 UTC
Attachment 191849 [details] pushed as d1e5161 - Document how to unset attributes