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 726998 - Misleading error message when closing file
Misleading error message when closing file
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: smb backend
git master
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2014-03-24 23:28 UTC by Ross Lagerwall
Modified: 2014-04-02 19:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
smb: Give correct error when unlink fails while closing file (1.34 KB, patch)
2014-03-24 23:32 UTC, Ross Lagerwall
committed Details | Review

Description Ross Lagerwall 2014-03-24 23:28:39 UTC
If you try and overwrite a file for which you don't have permission to delete, it fails with an error message of File Exists. Ideally, it would be Permission Denied.

Example:
$ gvfs-save smb://localhost/tmp/cat
dog
Error closing: File exists
Comment 1 Ross Lagerwall 2014-03-24 23:32:39 UTC
Created attachment 272823 [details] [review]
smb: Give correct error when unlink fails while closing file

When closing a file that is overwriting another file, don't ignore the
error message when unlinking the old file.  This is important when
unlinking fails due to a permission denied error but the error message
that was being returned was File Exists (from the subsequent rename).
Comment 2 Ondrej Holy 2014-04-02 13:29:57 UTC
Review of attachment 272823 [details] [review]:

Looks good, but I don't know if there is any reason to use temp file there. Why we aren't open the file directly with O_CREAT|O_TRUNC?
Comment 3 Ross Lagerwall 2014-04-02 14:02:49 UTC
(In reply to comment #2)
> Review of attachment 272823 [details] [review]:
> 
> Looks good, but I don't know if there is any reason to use temp file there. Why
> we aren't open the file directly with O_CREAT|O_TRUNC?

This is the same strategy that the glib local file implementation uses.  AFAIK it is safer and more atomic to write to a temp file and rename over.  You save to temp file, rename original to the backup (if needed) and then rename the temp file to the original file.
Comment 4 Ondrej Holy 2014-04-02 14:52:46 UTC
Comment on attachment 272823 [details] [review]
smb: Give correct error when unlink fails while closing file

It makes sense...
Comment 5 Ross Lagerwall 2014-04-02 19:21:15 UTC
Pushed to master as 449fd42ad5d8bc717c024e51f71bd8e913009025. Thanks!