Results 1 to 4 of 4

Thread: What is Geany doing when saving file?

  1. #1
    Join Date
    Aug 2012
    Beans
    185

    What is Geany doing when saving file?

    Hi,
    while tracking all (IN_ALL_EVENTS) file events with sys/inotify.h I got odd results when Geany modifies and saves a (text) file, for example:
    a text file is open in Geany, I add a letter to the file (to change its contents) and click save (Ctrl+S), the Geany "save" action triggers the following odd inotify events (event->mask printed bitwise) in the following order:

    Code:
    events triggered when listening for IN_ALL_EVENTS
    00000000 00000000 00000000 00100000 //IN_OPEN
    00000000 00000000 00000000 00001000 //IN_CLOSE_WRITE
    00000000 00000000 00000000 10000000 //IN_MOVED_TO
    00000000 00000000 00000000 00001000 //IN_CLOSE_WRITE
    00000000 00000000 00000000 00100000 //IN_OPEN
    00000000 00000000 00000000 00000001 //IN_ACCESS
    00000000 00000000 00000000 00010000 //IN_CLOSE_NOWRITE
    Notice the event chain starts with "IN_OPEN" (but the file was already open in Geany), also, IN_MOVED_TO is typically used for renaming files.
    So what is Geany doing?
    I thought it should be as simple as: (1) IN_MODIFY and (2) IN_CLOSE_WRITE, end of story, no?

  2. #2
    Join Date
    Mar 2007
    Location
    Linköping, Sweden
    Beans
    Hidden!

    Re: What is Geany doing when saving file?

    To be more robust against errors that may occur while saving the file it's possible that instead of simply overwriting an existing file, Geany is first saving the file to a temporary file name then renaming it to the desired name which might explain the IN_MOVED_TO event.

  3. #3

    Re: What is Geany doing when saving file?

    I'd say it's more likely that it renames the original to a backup file, and saves the modified copy under the original filename.

    It's possible some of these events are internal to Geany, and do not apply to the specific file you're editing. I don't know anything about Geany, but if it saves state from one invocation to the next, that has to be saved somewhere. Vim, for instance, stores temporary data in a dotfile in the current directory so that if your editing session gets killed between saves you won't have to lose everything.

  4. #4
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: What is Geany doing when saving file?

    You might want to have a play around with the Preferences - Various tab:

    http://www.geany.org/manual/#various-preferences

    In particular the settings you have for use_atomic_file_saving.

    Also whether you have the Backup Copy plugin installed:

    http://www.geany.org/manual/#backup-copy
    Please create new threads for new questions.
    Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •