Bug 497229 - You can write to the same .mny "cloud" file using two computers at the same time - file should be "locked" .
Summary: You can write to the same .mny "cloud" file using two computers at the same t...
Status: REPORTED
Alias: None
Product: kmymoney
Classification: Applications
Component: file (show other bugs)
Version: 5.1.3
Platform: unspecified Unspecified
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-09 10:23 UTC by david_crossley
Modified: 2025-04-01 12:20 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description david_crossley 2024-12-09 10:23:43 UTC
SUMMARY
I have a desktop and a laptop and have the software on both depending on if I am in my office or out and about the file is held one cloud storage (in this case onedrive).  If I accidentally leave the software running on my desktop,  I can still open the .kmy file w/r on the laptop.  I can then change things and close the laptop app.  When I get home and close the desktop app it overwrites the changes I made on the laptop.

STEPS TO REPRODUCE
1.  Open .mny file "cloud file e.g. onedrive" on first computer (desktop).
2.  Open the same .kmy file "cloud file" on the second computer (laptop).
3.  Make a change on the second computer (laptop).
4.  Save and close the application on the second computer (laptop).
5.  Accidental save or close/autosave etc. on first computer (desktop).


OBSERVED RESULT
The main "cloud file" no longer contains the changes as it is over written by the original file.

EXPECTED RESULT
The application should "lock" the open file to the first computer.  When the second computer tries to open the file, the application knows that the file is open on the first computer.  It then asks if you want to open read-only or take over read/write noting that you may loose any unsaved changes on the first computer (if you are auto saving this may not cause any issues as the first computer will have updated the .kmy file) and the second computer can take over the "lock".

The user then at least knows that they have two instances of the app trying to use the same file and can decide how to deal with it.

Note: Microsoft Money did this by renaming the file when it was open to something like .mny~locked I think. 

OR You could......  use some cleaver syncing type thing so that update appear on both at the same time....

SOFTWARE/OS VERSIONS

Desktop:  Windows 10 (KMymoney Version 5.1.3-eef04f1)
Laptop:  Linux Mint (KMymoney Version 5.1.3)


ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2025-03-25 12:30:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/269
Comment 2 Thomas Baumgart 2025-04-01 12:20:18 UTC
Git commit 8f5cf1c82a90869e2cc62bfc624a9de2336c0193 by Thomas Baumgart.
Committed on 01/04/2025 at 08:39.
Pushed by tbaumgart into branch 'master'.

Protect opening file multiple times by a lockfile

This locks the file on any mounted drive but not when you access it on
some sort of cloud storage using a http(s) based URL.
Related: bug 475674
FIXED-IN: 5.2

M  +5    -0    kmymoney/interfaces/kmymoneyplugin.cpp
M  +20   -0    kmymoney/interfaces/kmymoneyplugin.h
M  +18   -24   kmymoney/kmymoney.cpp
M  +0    -2    kmymoney/kmymoney.h
M  +4    -0    kmymoney/plugins/gnc/import/gncimporter.cpp
M  +1    -0    kmymoney/plugins/gnc/import/gncimporter.h
M  +4    -0    kmymoney/plugins/sql/sqlstorage.cpp
M  +1    -0    kmymoney/plugins/sql/sqlstorage.h
M  +286  -184  kmymoney/plugins/xml/xmlstorage.cpp
M  +7    -25   kmymoney/plugins/xml/xmlstorage.h

https://invent.kde.org/office/kmymoney/-/commit/8f5cf1c82a90869e2cc62bfc624a9de2336c0193