Skip to content

Let user "Save As..." when document has been externally modified

Two commits that should not be squashed. Each one's commit message should be self-explanatory. I would like to cherry-pick the first one to the stable branch, as it fixes a data loss issue.

Author: Nate Graham <nate@kde.org>
Date:   Thu Apr 20 14:13:31 2023 -0600

    Let user "Save As..." when document has been externally modified
    
    Currently Okular stops the user from saving their document if it has
    unsaved changes and was modified externally. This makes some sense
    because there are now two sources of truth, and Okular cannot reconcile
    them itself. However as a consequence, it causes data loss since the
    user's unsaved changes in Okular become un-save-able. This is quite
    frustrating when it happens.
    
    But this prohibiton on saving over an externally-modified document only
    really makes sense for a "Save" operation that overwrites the original
    document. If instead, the user does a "Save As...", then they can save
    their local changes to another file and avoid losing unsaved changes.
    Then if needed, they can manually compare the original
    externally-modified document with their newly-saved document and
    reconcile the changes by hand.
    
    Accordingly, this commit avoids showing the error message box and
    blocking saving if the user is doing a "Save As..." to a new location,
    rather than overwriting the open file.
    
    BUG: 402017
    FIXED-IN: 23.04.1
Author: Nate Graham <nate@kde.org>
Date:   Thu Apr 20 14:19:26 2023 -0600

    Offer options when trying to overwrite externally-modified file
    
    When the user tries to do a "Save" operation on an open file that was
    since modified externally, currently Okular prohibits it. We can make
    this a bit more user-friendly by instead explaining the situation
    clearly and offering the user some options:
    - Yes, really overwrite the changes made in the other program
    - Instead save the unsaved changes as a new file elsewhere
    - Abort
    
    CCBUG: 402017

Test Plan

  1. Open a PDF document in Okular
  2. Start to annotate it or fill out forms, but do not save
  3. From outside of Okular, open the file in LibreOffice Draw or Xournal++, annotate it there, and save over the original document
  4. Go back to Okular
  5. Invoke "Save As..." with no trouble
  6. Do it all again up to step 5 and then invoke "Save" and see a warning dialog box with options for what to do

Merge request reports