Bug 361956

Summary: KSaveFile breaks hard links
Product: [Unmaintained] kdelibs Reporter: x <rot26>
Component: kdecoreAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: grave CC: faure
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description x 2016-04-19 09:11:50 UTC
Hard links are not preserved by KDE applications

Reproducible: Always

Steps to Reproduce:
1. Create a file (a text file will do)
2. Create a HARD link to that file
3. Open one of the links with Kate (for example)
4. Do some edits
5. Save (NOT Save As!)

Actual Results:  
A new file is created, replacing the original one, with the result that the hard link is broken.

Expected Results:  
Hard links should be preserved.

This is a pretty major fail and has caused me quite a bit of lost time trying to figure out why whatever modifications I was doing to a source code file were not being taken into account.

Eventually I realised what was going on, but right now I cannot use neither Kate nor KWrite as my editor. I'm back to vim. :-(
Comment 1 x 2016-04-19 09:36:42 UTC
I found bug 316240.

This comment by David Faure is relevant: https://bugs.kde.org/show_bug.cgi?id=316240#c4

Then this change review: https://codereview.qt-project.org/#/c/52059/

There Thiago Macieira says:
> Hardlinks being split up is not a bug, it's a feature.

With further explanations:

> Who says the effects are undesireable?

At least I, the author of bug 316240, and the five voters on same. :-)

> The hardlink may have been placed there so a backup copy could exist if the file got modified.

Or it may not. It is totally not up to the developer to second guess a user's intention. Especially not on so flimsy grounds.

Surely if one wants a backup copy one makes a COPY of a file, not a hard link? Can anybody point to an actual and intended example of this "backup by hard link" scenario?

> Think of how Git shares object files between repositories: a hardlink is created and, if the file is modified for any reason (not one of the WORM files), it breaks the hardlink -- COW behaviour.

Yes but Git controls all access to those files: the user never accesses them directly. This is *not* the case with the sort of files that KSaveFile is going to be operating on.

Please note that:
1. Every other text editor in the known universe preserves hard links.
2. This results in inconsistent behaviour depending on whether a hard or soft link has been used (the latter are preserved).

Sorry, but I really do think that this is most definitely a bug, not a feature.
Comment 2 David Faure 2016-04-22 15:12:09 UTC
KSaveFile no longer exists in KF5.

Is this about Qt4/kdelibs4, or about Qt5's QSaveFile?
Comment 3 x 2016-04-23 19:43:27 UTC
(In reply to David Faure from comment #2)
> KSaveFile no longer exists in KF5.
> 
> Is this about Qt4/kdelibs4, or about Qt5's QSaveFile?

My apologies, QSaveFile I imagine? I'm on KDE Frameworks 5.18.0, Qt 5.5.1.
Comment 4 Justin Zobel 2022-10-20 23:54:36 UTC
Thank you for reporting this bug in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you!
Comment 5 Bug Janitor Service 2022-11-04 05:07:22 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Bug Janitor Service 2022-11-19 05:14:48 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!