Bug 358984 - Saving changes inode number of hard linked files
Summary: Saving changes inode number of hard linked files
Status: RESOLVED FIXED
Alias: None
Product: KBibTeX
Classification: Applications
Component: General (other bugs)
Version First Reported In: 0.7
Platform: Compiled Sources Linux
: NOR minor
Target Milestone: ---
Assignee: Thomas Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-04 14:24 UTC by Tudor Protopopescu
Modified: 2016-11-03 20:29 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tudor Protopopescu 2016-02-04 14:24:41 UTC
Not sure this is actually a bug or expected behaviour.

I have a .bib file in a directory and I have created a hard linked .bib in another directory. After doing this both have the same inode number. Modifying one of the files, doesn't matter which, changes its inode, breaking the link.

System:

Git revision 90e6d7a (0.7)
KDE 4.14.10

Observed same behaviour with version 0.6, installed from openSUSE 13.1 KDE repo.




Reproducible: Always

Steps to Reproduce:
1. Create a hard link to a .bib file in a different directory (ln /path/to/bibfile.bib linkedfile.bib). 
2. Observe bibfile.bib and linkedfile.bib have the same inode.
3. Open one of them, modify and save.
4. Observe that the inode of the modified file is now different.

Actual Results:  
Inode number of hardlinked file changes upon save.

Expected Results:  
Inode number of hardlinked files should remain the same.

Use case: I keep my .bib files in a `references' directory, but I need a .bib file in a project directory which is under version control, so that I can push and pull changes to the .bib file, and I don't want to maintain two files. Symlinking to the file in the `references' directory doesn't work, since only the reference to the symlinked file is pushed. Solution: create a hard link to the `central' file.

Note: creating the link in the 'central' dir to the file in the project directory has the same result. 

Workaround: creating a symlink in 'central' to the file in the project directory will do the job.
Comment 1 Thomas Fischer 2016-03-01 21:45:01 UTC
Please test branch 'bugs/kde358984' on my personal Git repository on KDE: https://quickgit.kde.org/?p=clones%2Fkbibtex%2Fthomasfischer%2Fkbibtex.git
The relevant commit is http://commits.kde.org/clones/kbibtex/thomasfischer/kbibtex/47dff0a5ef101343ba9aafbd8538fe2d96052d40
Comment 2 Thomas Fischer 2016-08-11 19:52:13 UTC
I replace commit 47dff0a5ef101343ba9aafbd8538fe2d96052d40 with a better commit 5884726b8fd4e218b800a47b1be9fb78a4e9d538, thus rewriting the Git history for the 'bugs/kde358984' branch on 'clones/kbibtex/thomasfischer/kbibtex'.

Can you please check and verify if the bug you reported is fixed now?
Comment 3 Thomas Fischer 2016-11-03 20:29:17 UTC
Git commit b72743cd7532e167751f0d2788c8509301ae5515 by Thomas Fischer.
Committed on 03/11/2016 at 20:25.
Pushed by thomasfischer into branch 'kbibtex/0.7'.

Refactoring writing files

This patch addresses issues when writing bibliography
files, as it gets apparent when writing a file with
multiple hard links.

The changes introduced with this commit include:
- When writing to local files, no temporary file is
  used. Instead, the target file gets directly
  overwritten.
  If the local filename is a symbolic link, the real
  file the symbolic link points to will get
  overwritten. Backup files' names will be based on
  the symbolic links' names, not the real files'
  names.
  For remote files, a local temporary file is used
  to write data to before uploading this temporary
  file to its target location.
- In case of errors, a message box may get shown.
  If the bibliography exporter added text to an
  error log, a special message box listing those
  error messages will be shown.

M  +73   -45   src/parts/part.cpp

http://commits.kde.org/kbibtex/b72743cd7532e167751f0d2788c8509301ae5515