#443 Saving remote files causes a wipe of the file

pending
General (289)
9
2012-09-14
2010-03-01
jazzor
No

Starting from Geany 0.18.1, saving of remote files when opened via gvfs will cause the file to be wiped.

This is a MAJOR regression stemming from this commit:
* src/document.c:
Allow saving remote files using g_file_set_contents() as well
(patch by Алексей Антипов, thanks).

I don't know who's idea or theory it was to do this but I can assure you that it is wiping files. Someone should have tested this more thoroughly.

Discussion

  • jazzor

    jazzor - 2010-03-01
    • labels: --> General
    • priority: 5 --> 9
     
  • Christian Þ

    Christian Þ - 2010-03-08

    This bug just hit me, too. I was trying to save a file opened in Nautilus with a dav:// URL.
    I am using Ubuntu 9.10 in a de_DE.UTF-8 locale. Other version numbers:
    geany 0.18 (built on Aug 24 2009 with GTK 2.17.7, GLib 2.21.4)

    Btw. other editors (e.g. gvim) also have problems saving to a dav:// URL, but they do not blank the file. gedit works just fine here.

     
  • Brad Wilson

    Brad Wilson - 2010-03-17

    Yes, this has happened to me too, every time that I try to save a remote file in Geany that I am connected to through FTP via .gvfs it effectively wipes it out. The only time that I do not end up with a 0 byte file after a save is if I am creating the file for the first time, but every subsequent time will produce the problem. If I "save as" an already existing file and change the name it will save the file properly too.

    This has happened to me on 3 completely different hosts using FTP via .gvfs every time I save an existing file from within Geany.

    It does not seem to happen when I am connected through SSH.

    My environment:
    geany 0.18 (built on Aug 20 2009 with GTK 2.16.1, GLib 2.20.1)
    Ubuntu 9.04

    When trying to save I get a GTK error dialogue:

    "Error saving file. Input/output error"

    Then I can inspect the file from Nautilus and see that it is 0 bytes, it also is empty when trying to re-open in Geany or Gedit.

    And running geany with the -v option shows:

    (geany:10600): Gtk-WARNING **: Operation not supported by backend

    (geany:10600): Gtk-WARNING **: Operation not supported by backend

    (geany:10600): Gtk-WARNING **: Operation not supported by backend

    Hope somebody fixes this as I love Geany, and I do a lot of work for clients who use FTP. Thanks much!

     
  • jazzor

    jazzor - 2010-03-17

    I figured out that theres a hidden settings in ~/.config/geany called "use_safe_file_saving"

    just change it to use_safe_file_saving=true and it should work for ssh://.

    This setting should definitely be on by default.

     
  • Brad Wilson

    Brad Wilson - 2010-03-18

    SSH worked fine before, the problem (at least in my case) is FTP through gvfs. I changed that setting to true, but it did not affect the FTP bug. When using FTP through gvfs I still end up with a 0 byte file after saving in Geany.

     
  • Enrico Tröger

    Enrico Tröger - 2010-03-29
    • assigned_to: nobody --> eht16
     
  • Enrico Tröger

    Enrico Tröger - 2010-03-29

    You are talking about different problems.
    rhift's problem is a GVfs bug which is known and exists since a long time, it's not Geany's fault GVfs has problems with some FTP servers. Better to not use FTP anyway. See https://bugzilla.gnome.org/show_bug.cgi?id=585992.

    jazzor's bug seems actually to be a regression. Sorry for that. I'll look a bit deeper into this soon.

     
  • Alexey Antipov

    Alexey Antipov - 2010-03-31

    Hi!

    As I'm the author of that patch, I'd like to explain some things.

    First, please consider the following GVFS issues: https://bugzilla.gnome.org/show_bug.cgi?id=608910 and https://bugzilla.gnome.org/show_bug.cgi?id=608908. The first one seems exactly the same as explained here. Both appear to happen when using low-level file API (fopen(), fprintf() etc.).

    The solution to use higher-level API (g_file_set_contents) seems to deal with it, re-writing the whole file. If there are issues with this (when running Geany with use_safe_file_saving=true on remote filesystems), please provide some moredetailed information, i.e. target folder and file permissions and backend type. I have tested this with sftp:// and smb:// backends (after having lost some data without use_safe_file_saving:()

    Second, it seems that at least gedit uses GIO API (GFile) that should work OK "by design". Though "Using the GIO API would require GLib 2.16. Currently we depend on 2.8." (see http://lists.uvena.de/geany-devel/2010-March/002079.html\).
    IMHO the use of GIO API is probably the best solution here, though there should be an agreement between the developers. If you are interested and are using GLib>=2.16, I can send you another patch that makes Geany use GIO for file saving.

    Please feel free to contact me at 1a_antipov<at>mail.ru

     
  • Lex Trotman

    Lex Trotman - 2012-09-14
    • status: open --> pending
     
  • Lex Trotman

    Lex Trotman - 2012-09-14

    File saving has changed since this was last actioned, does it still cause problems with use_atomic_file_saving off?

     

Log in to post a comment.