Bug 36730: (Bug 35428 follow-up) po files (sometimes) fail to update
authorJanusz Kaczmarek <januszop@gmail.com>
Tue, 30 Apr 2024 10:18:12 +0000 (10:18 +0000)
committerLucas Gass <lucas@bywatersolutions.com>
Tue, 28 May 2024 21:44:03 +0000 (21:44 +0000)
commit1d2959a93de2fbeabeb731abeac58bed8378d187
treea3e7eb11089c69e62a8c1ad4ec35e7f48feb962c
parent6eaef9ec6f64d92daf4fcaa39e72149fb76b3a6c
Bug 36730: (Bug 35428 follow-up) po files (sometimes) fail to update

Under some circumstances (e.g. non-standard disk latency) po files fail
to be generated.  The output from the gulp po:update --lang xx-XX task
is than like this:

[10:01:39] 'po_update_staff' errored after 6.41 s
[10:01:39] Error: ENOENT: no such file or directory, open '/tmp/koha-5WCc9s/Koha-staff-prog.pot'

This is due to the time dependencies inside the function flush (callback)
(in the function xgettext) in gulpfile.js.  It happens that the
/tmp/koha-NNNNNN folder gets deleted before the asynchronous callback
function called by fs.readFile is completed.  The callback should copy
the content of the .pot file from /tmp/koha- to its final destination,
while, in parallel in fact, the folder inside /tmp is being removed.
This creates a race condition.

Test plan:
==========
Hard to reproduce.  But the race condition found in the code should
be obvious.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 67b3cbd438f0cee378cfa5236f2673ab6ea32f33)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 5291e6b6b5118e08c6bcd38e559029c8b800003e)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
gulpfile.js