Bug 396343 - When saving the file, I am always warned that file has changed in disk
Summary: When saving the file, I am always warned that file has changed in disk
Status: RESOLVED FIXED
Alias: None
Product: KBibTeX
Classification: Applications
Component: Loading/saving files (show other bugs)
Version: 0.8.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Thomas Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-09 17:44 UTC by Nicolas Vaughan
Modified: 2018-07-18 18:41 UTC (History)
0 users

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


Attachments
screenshot (237.98 KB, image/png)
2018-07-09 17:44 UTC, Nicolas Vaughan
Details
Delay resume watching a file for modifications after saving said file (756 bytes, patch)
2018-07-14 18:23 UTC, Thomas Fischer
Details
Patch to part.cpp (756 bytes, patch)
2018-07-15 19:32 UTC, Nicolas Vaughan
Details
New Archi Linux PKGBUILD, modified to run patch file. (990 bytes, text/plain)
2018-07-15 19:33 UTC, Nicolas Vaughan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Vaughan 2018-07-09 17:44:34 UTC
Created attachment 113848 [details]
screenshot

Even if I have not changed the file with another application, I always get a dialogue saying that it has been changed.
Comment 1 Thomas Fischer 2018-07-14 18:23:07 UTC
Created attachment 113931 [details]
Delay resume watching a file for modifications after saving said file

I suspect the problem you observe is due to the file's location in a directory synchronized via DropBox (visible in the screenshot). This patch introduces a 500 milliseconds delay between saving a file and resuming watching it for external modifications. Please test if this patch fixes your problem. Also, try different time values to find a "sweet spot" when it starts/stops working.

I recommend to apply this patch by building an ArchLinux package based on the original PKGBUILD file:
https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/kbibtex
Please check the official ArchLinux documentation on how to apply a patch inside a PKGBUILD file.
Comment 2 Nicolas Vaughan 2018-07-15 04:09:24 UTC
Hi Thomas,
Thanks for your reply. The patch works perfectly. (I had some trouble patching and compiling the Arch package, but in the end everything worked fine.)
Comment 3 Thomas Fischer 2018-07-15 17:38:48 UTC
(In reply to Nicolas Vaughan from comment #2)
> Hi Thomas,
> Thanks for your reply. The patch works perfectly. (I had some trouble
> patching and compiling the Arch package, but in the end everything worked
> fine.)

Sounds good! One more question: my patch uses an arbitrarily chosen delay of 500ms. Does the patch work as well with a delay of, say, 50ms? Please test some vales between 5 and 500 to find the "breaking point".
Comment 4 Nicolas Vaughan 2018-07-15 19:32:00 UTC
Created attachment 113953 [details]
Patch to part.cpp

This is Thomas' original patch for part.cpp.
Comment 5 Nicolas Vaughan 2018-07-15 19:33:15 UTC
Created attachment 113954 [details]
New Archi Linux PKGBUILD, modified to run patch file.
Comment 6 Nicolas Vaughan 2018-07-15 19:45:25 UTC
To create an Arch Linux package which incorporates the patch, do as follows:

1. Clone the Arch AUR repo: git clone https://aur.archlinux.org/kbibtex-git.git
2. CD into the directory: cd kbibtex-git
3. Replace original PKGBUILD with the one I have attached here.
4. Copy the patch file part.patch into the directory.
5. Create the package: makepkg -s (or, if you want to install it immediately: makepkg -si)
6. Install the package: sudo pacman -U kbibtex-git-r2888.5d462666-1-x86_64.pkg.tar (or whatever the resulting package name is).


The changes I made in PKGBUILD are just two lines at the beginning of the prepare() function:

prepare() {
   cd ..
   patch "$srcdir"/kbibtex/src/parts/part.cpp part.patch
   cd "$srcdir"
   mkdir build
}
Comment 7 Thomas Fischer 2018-07-18 18:41:36 UTC
Git commit f959986e4c582f24c492c96d2022c50b52cfc62b by Thomas Fischer.
Committed on 18/07/2018 at 18:34.
Pushed by thomasfischer into branch 'kbibtex/0.8'.

DropBox-synchronized folders no longer cause 'reload' messages

It is strongly suspected that when saving a file in a folder
synchronized via DropBox, the DropBox client modifies(*) the file
right after it was saved in KBibTeX, causing KBibTeX to ask the
user if the file was to be reloaded or on-disk changes to be
ignored.
By delaying resuming watching a local file after it has been saved to
disk by 500ms, this problem is no longer apparent.

(*) The file's content does not seem to be changed, but some filesystem
metadata may get touched/modified, triggering the file watching service.
FIXED-IN: 0.8.2

M  +12   -4    src/parts/part.cpp

https://commits.kde.org/kbibtex/f959986e4c582f24c492c96d2022c50b52cfc62b
Comment 8 Thomas Fischer 2018-07-18 18:41:43 UTC
Git commit acac51d20183f6b853223602f0cda4524a3502b6 by Thomas Fischer.
Committed on 18/07/2018 at 18:40.
Pushed by thomasfischer into branch 'master'.

DropBox-synchronized folders no longer cause 'reload' messages

It is strongly suspected that when saving a file in a folder
synchronized via DropBox, the DropBox client modifies(*) the file
right after it was saved in KBibTeX, causing KBibTeX to ask the
user if the file was to be reloaded or on-disk changes to be
ignored.
By delaying resuming watching a local file after it has been saved to
disk by 500ms, this problem is no longer apparent.

(*) The file's content does not seem to be changed, but some filesystem
metadata may get touched/modified, triggering the file watching service.

This commit was cherry-picked from branch 'kbibtex/0.8', commit
f959986e4c582f24c4.

M  +12   -4    src/parts/part.cpp

https://commits.kde.org/kbibtex/acac51d20183f6b853223602f0cda4524a3502b6