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 550795 - [PATCH] GFileCopy flag to preserve permissions of target file in a copy operation
[PATCH] GFileCopy flag to preserve permissions of target file in a copy opera...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.18.x
Other All
: Normal enhancement
: ---
Assigned To: Alexander Larsson
gtkdev
Depends on:
Blocks: 550816
 
 
Reported: 2008-09-04 08:43 UTC by Nelson Benitez
Modified: 2008-09-22 00:05 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Add GFileCopyFlag (2.13 KB, patch)
2008-09-04 08:58 UTC, Nelson Benitez
needs-work Details | Review
Take two (3.43 KB, patch)
2008-09-08 08:23 UTC, Nelson Benitez
accepted-commit_now Details | Review

Description Nelson Benitez 2008-09-04 08:43:44 UTC
Hi!,
this feature got added in gnomevfs right before gio appeared, but gio doesn't have it, see bug 309604 for original request of feature in gnomevfs. I want this feature to be able to DnD a folder from a nautilus cdrom window and drop it in my desktop with default perms, so I can put/modify files in it. Currently the folder/files are copied with readonly perms because that are of the source location (cdrom mount).

I will file a nautilus bug about that and make it depend on this.
Comment 1 Nelson Benitez 2008-09-04 08:58:29 UTC
Created attachment 117990 [details] [review]
Add GFileCopyFlag

Adds a GFileCopyFlag, that flag is read in g_file_copy_attributes(), if it's found then we remove the "unix::mode"[1] attribute from the attributes that are going to be copied to dest file/folder.

This is so because file_copy_fallback() first copies the file then sets its attributes (including perms) with a g_file_copy_attributes() from the source to dest. 

[1] Which is the attribute that carries the perms.
Comment 2 Nelson Benitez 2008-09-04 09:01:25 UTC
Flag description is:
G_FILE_COPY_TARGET_DEFAULT_PERMS: Leaves target file with default perms, instead of setting the source file perms.
Comment 3 Matthias Clasen 2008-09-06 22:15:02 UTC
The idea makes sense to me, the implementation not so much. 

Instead of using regex, I'd rather see this being done while assembling the attribute string, inside build_attribute_list_for_copy, or more specifically,
should_copy() should pay attention to this flag.
Comment 4 Nelson Benitez 2008-09-08 08:23:47 UTC
Created attachment 118278 [details] [review]
Take two

New patch follows Matthias comments, I also like it over the previous one :).

Unrelated note
 Shouldn't glib has a function for replacing strings? when I searched for it my only option was to use g_regex_replace (), which seems overkill just to replace some plain strings.
Comment 5 Matthias Clasen 2008-09-10 22:35:32 UTC
Stylistically, I slightly prefer 

bool = foobar & flag != 0

over

bool = foobar & flag


Other than that, it looks fine.
Comment 6 Matthias Clasen 2008-09-10 23:26:43 UTC
Actually, I meant: commit after we branch
Comment 7 Nelson Benitez 2008-09-11 07:45:10 UTC
Ok, I still don't have commit access, so please do it for me.
Comment 8 Nelson Benitez 2008-09-18 16:02:57 UTC
I will commit it tomorrow morning...
Comment 9 Nelson Benitez 2008-09-22 00:05:45 UTC
I've just commited the patch so this is fixed :-), thank you!