Fix translation count and find precedence in the download step - #17
Open
SNO7E-G wants to merge 1 commit into
Open
Fix translation count and find precedence in the download step#17SNO7E-G wants to merge 1 commit into
SNO7E-G wants to merge 1 commit into
Conversation
Two issues in download_translations' extraction step, same block: - moved_count was incremented inside a `find ... | while read` pipeline, which runs in a subshell, so the parent counter never changed and the "Moved N files" log always reported 0. Feed the loop with process substitution so the count survives. - `find -type f -name "*.json" -o -name "*.po" ...` bound -type f only to the first -name, so a directory named like a match could slip through. Group the -name alternatives with \( \) so -type f applies to all of them. Success/failure and cleanup behaviour is preserved via a move_failed flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary. Two correctness fixes in
download_translations' extraction block.Problem.
moved_countwas incremented inside afind … | while readpipeline, which runs the loop in a subshell — the parent counter never changed, so the "Moved N files" log always reported 0, even on a successful unpack.find … -type f -name "*.json" -o -name "*.po" …binds-type fonly to the first-name(find's implicit-ais tighter than-o), so the other extensions matched entries of any type — a directory named like a match could enter the move loop.Change. Feed the loop via process substitution (
while … done < <(find …)) somoved_countand a newmove_failedflag survive; group the-namealternatives with\( … \)so-type fapplies to all (regular files only).The success/failure contract is preserved exactly: a failed move logs a warning, sets
move_failed, breaks; the post-loop check then logs the error,rm -rfs both temp paths, returns 1. Success cleans up and returns 0.Risk. Localised to the extract/move block; no interface change. One cosmetic shift — the rare "mv succeeded then file vanished" sub-case now logs the generic "Failed to move" message rather than its own text (same detection, abort, cleanup).
Verified.
bash -nclean; a harness mirroring the new block moves 3 real files (count = 3) while a directory namedd.poand a.txtare skipped. This block runs only on a real HTTP-200 zip (no stubbed suite reaches it), so the harness is the achievable check without a live token. Independent review confirmed failure path + cleanup preserved andset -e-safe. Rebased cleanly onto v1.0.3; bug confirmed still present upstream at ~lines 2498–2530.