Warn users if a file has been edited since last saved

Issue #325 resolved
Adam Winer created an issue

Many users are saving their entries on networked drives (or DropBox, etc.) so they can access from multiple machines. This is great unless you save from one while it's still open on another.

Comments (4)

  1. drewbenn

    I'm going to get hit by this sooner or later (if I haven't already), so I thought I'd take a stab at it.

    Rather than reporting when the file is modified underneath Scythebill (similar to how emacs does it), it just grabs the last-modified timestamp when opening a file, then waits until the user goes to Save and compares the stored timestamp to the file's current last-modified timestamp (and saves the timestamp again after saving). I didn't see any other paths through the code to save the file to disk or to open a file (where the file's timestamp needs to be recorded), but if there are any they need to be modified to support this, too.

    The dialog box has a different icon in the corner (a small penguin? instead of the Scythebill icon) than other popups have, I don't know why. I based the text off the emacs messages when a file is modified, but they should probably be rewritten in a more-Scythebill style. Sorry I can't provide Spanish translations.

    When exiting, if this dialog comes up (after pressing Yes to, do you want to save: yes|no|cancel) and you press No, Scythebill just exits. Should there be a way to cancel (and avoid exiting), instead?

    When you have a file open, and you File | Open... and select that same file, the file does not get reloaded from disk (that is existing behavior). Is that expected, and if so, what should the behavior be if the file was touched by some other program before it was "re-opened?" Right now, if you do that you won't get this warning when you try to save (see comment in LastModified.java).

    Should probably call removeFile() when closing a file, but I never looked for the close file code paths.

    Tested on Linux (Debian stable) only (I can't test on Windows or OS X):

    • Open Scythebill
    • Remove a report
    • File | Save -- verify no popup and Save option is greyed out
    • in a terminal, verify the query is removed from the file
    • Remove another report
    • in a terminal, touch file.bsxm
    • File | Save -- verify popup, press No
    • in a terminal, verify the query still exists in the file
    • File | Save -- verify popup, press Yes, verify Save option is greyed out
    • in a terminal, verify the query is removed from the file

    • Enter Sightings, enter a location, Next, Next, enter one bird and Add Species
    • in a terminal, touch file.bsxm
    • Done ('... and save' is checked) -- verify popup, press No
    • in a terminal, verify the new visit isn't in recentEdits
    • Enter Sightings, recent visit (that new visit), Next, Next
    • Done ('and save' is checked) -- verify popup, press Yes, verify Save option is greyed out
    • in a terminal, verify the new visit is now in recentEdits

    • Open file #2
    • File2: Remove a report
    • File2: in a terminal, touch file2.bsxm
    • File2: File | Save -- verify popup, press No
    • File1: Remove a report
    • File1: File | Save -- verify no popup
  2. Adam Winer reporter

    Hrm… I think this heads in the wrong direction. Once you need to save, you’ve already lost data.

    What I think I’d like to see:

  3. Adam Winer reporter

    Resolve issue #325: Warn users if a file has been edited since last saved Shows a warning alert if a file has been modified when a window is activated or the user navigates to a new part of the app. Gives the user the option of either reloading from disk, or of ignoring the changes.

    → <<cset ced4b8f3a4db>>

  4. Log in to comment