GNOME Bugzilla – Bug 726998
Misleading error message when closing file
Last modified: 2014-04-02 19:21:44 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
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).
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?
(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 on attachment 272823 [details] [review] smb: Give correct error when unlink fails while closing file It makes sense...
Pushed to master as 449fd42ad5d8bc717c024e51f71bd8e913009025. Thanks!