fix(dictionary): no language goes missing while the curator updates
The update removed the files of sources no longer wanted first, Korean's words from Wiktionary among them, before KRDict's replacement was written, which on the first run after v0.16.0 came after Wiktionary's 3 GB conversion: the server unloaded Korean meanwhile, and for good if KRDict failed. Removal now comes last, and a replaced source stays until its replacement is there. A bare curate update, without --languages, no longer removes every other language. A KRDict export of another shape (the page's buttons reordered) is refused rather than written as a dictionary of no words over Korean's. The server never unloads from an empty dictionaries folder (a volume made anew), and a failed unload no longer stops the files from loading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
31eed85aff
commit
d5fe51b296
1 changed files with 84 additions and 12 deletions
|
|
@ -196,6 +196,9 @@ Future<void> main(List<String> args) async {
|
|||
Directory(options.option('data')!),
|
||||
days,
|
||||
languages: _languages(options.option('languages')),
|
||||
// Without --languages, the files of other languages are left as
|
||||
// they are: an operator may keep them up to date otherwise.
|
||||
removesOthers: options.option('languages') != null,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
@ -536,6 +539,7 @@ Future<void> _update(
|
|||
Directory data,
|
||||
int? every, {
|
||||
Set<String> languages = const {},
|
||||
bool removesOthers = true,
|
||||
}) async {
|
||||
final (:wiktionary, :chinese, :korean, :greek) = dictionarySources(languages);
|
||||
void say(String message) =>
|
||||
|
|
@ -599,17 +603,22 @@ Future<void> _update(
|
|||
),
|
||||
);
|
||||
// In this order: Korean's words and Hanja take what Wiktionary kept.
|
||||
// What is no longer wanted goes last, once what replaces it is there.
|
||||
Future<bool> languagesOnce() async {
|
||||
final removed = removeUnwanted(into, languages);
|
||||
final done =
|
||||
!(!await chineseOnce() |
|
||||
!await wiktionaryOnce() |
|
||||
!await koreanOnce() |
|
||||
!await charactersOnce());
|
||||
final removed = removesOthers
|
||||
? removeUnwanted(into, languages)
|
||||
: const <File>[];
|
||||
if (removed.isNotEmpty) {
|
||||
say(
|
||||
'Removed ${[for (final file in removed) file.uri.pathSegments.last].join(', ')}.',
|
||||
);
|
||||
}
|
||||
return !(!await chineseOnce() |
|
||||
!await wiktionaryOnce() |
|
||||
!await koreanOnce() |
|
||||
!await charactersOnce());
|
||||
return done;
|
||||
}
|
||||
|
||||
if (every == null) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue