Bug 424033 - Can't associate a file with a relative path without having the file copied
Summary: Can't associate a file with a relative path without having the file copied
Status: RESOLVED FIXED
Alias: None
Product: KBibTeX
Classification: Applications
Component: User interface (show other bugs)
Version: git (master)
Platform: Manjaro Linux
: NOR major
Target Milestone: ---
Assignee: Thomas Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-09 18:58 UTC by nobodyinperson
Modified: 2020-07-24 17:47 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nobodyinperson 2020-07-09 18:58:49 UTC
SUMMARY

When linking an external PDF, the ”Do not copy or move document” option is not honored. Instead, the linked file is copied next to the bibliography file and the path to the original file is lost and set only to the filename.

STEPS TO REPRODUCE
1. Create a new bibliography.
2. Add an entry.
3. In the dialog, switch to the External tab and click ”Add file” --> ”Add reference”
4. Select a file in a folder or subfolder next to the bibliography file (at least so that a relative path makes sense)
5. In the next dialog, keep all settings at their default (don't move or copy, relative path). Up until now everything is fine.
6. Click OK. Now the weirdness begins.

OBSERVED RESULT

- The link to the file (which was displayed correctly in the preview dialog) is stripped down to only the filename.
- The selected file is copied next to the bibliography file.

So it seems that the second option (Copy file next to bibliography) is forced.


EXPECTED RESULT

- The relative path is used as shown in the preview.
- The linked file is neither moved nor copied but left in peace (As is the case with KBibTeX stable 0.9.2)

SOFTWARE/OS VERSIONS

- up-to-date Manjaro XFCE, built from AUR or with run-kbibtex.sh from upstream master (0c711606), same result.

ADDITIONAL INFORMATION

I browsed the relevant source code (src/gui/element/associatedfilesui.cpp and src/networking/associatedfiles.cpp obviously) but couldn't find the problem on the quick.
Comment 1 Thomas Fischer 2020-07-16 21:22:43 UTC
I think I fixed the bug. It was simply the case that the copy function was called both for move (just copy followed by a 'delete file'), copy, and 'don't do anything', instead of just the first two cases.

I applied the fix to the 0.10 code base. If you can confirm that the problem is fixed, I'll apply it to 'master' as well.

The change can be seen here: https://invent.kde.org/thomasfischer/kbibtex/commit/425c757f507ad83f7b98970071d2de9187a3904f
Comment 2 nobodyinperson 2020-07-23 13:21:43 UTC
I built KBibTeX for this commit: https://invent.kde.org/thomasfischer/kbibtex/-/commit/425c757f507ad83f7b98970071d2de9187a3904f and it seems to have fixed the bug.

Thanks for fixing this!

Yann
Comment 3 Thomas Fischer 2020-07-24 17:46:36 UTC
Git commit 02c927722365768b470c941221e38e51debb07ad by Thomas Fischer.
Committed on 24/07/2020 at 17:46.
Pushed by thomasfischer into branch 'kbibtex/0.10'.

If user selects 'do not move/copy file', don't move/copy file
FIXED-IN: 0.10

M  +1    -0    ChangeLog
M  +4    -0    src/networking/associatedfiles.cpp

https://invent.kde.org/office/kbibtex/commit/02c927722365768b470c941221e38e51debb07ad
Comment 4 Thomas Fischer 2020-07-24 17:47:49 UTC
Git commit 75f6a5135d8bd9d013e2654e944bbb31d8bcab38 by Thomas Fischer.
Committed on 24/07/2020 at 17:46.
Pushed by thomasfischer into branch 'master'.

If user selects 'do not move/copy file', don't move/copy file

Forward-port of commit 02c927722365768b470c from branch 'kbibtex/0.10'.

M  +1    -0    ChangeLog
M  +4    -0    src/networking/associatedfiles.cpp

https://invent.kde.org/office/kbibtex/commit/75f6a5135d8bd9d013e2654e944bbb31d8bcab38