diff options
author | Martin Weinelt <mweinelt@users.noreply.github.com> | 2023-01-31 15:36:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-31 15:36:45 +0000 |
commit | e60ddddbbbf50b3f2a45d40001c1bb2ab0df204d (patch) | |
tree | 9cf00786a7ced4bc7ed4d5bc3e48f6411766dcc1 /nixos/modules/services/misc/paperless.nix | |
parent | 96d4702261d2b6238348d93e35d24373842cef59 (diff) | |
parent | a7d112b30a36fd4f0500fed41c62249461624c98 (diff) |
Merge pull request #213489 from mweinelt/paperless-update
paperless-ngx: 1.11.3 -> 1.12.2
Diffstat (limited to 'nixos/modules/services/misc/paperless.nix')
-rw-r--r-- | nixos/modules/services/misc/paperless.nix | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/nixos/modules/services/misc/paperless.nix b/nixos/modules/services/misc/paperless.nix index 1dddd147ac09..667f16d98f82 100644 --- a/nixos/modules/services/misc/paperless.nix +++ b/nixos/modules/services/misc/paperless.nix @@ -226,9 +226,26 @@ in # Auto-migrate on first run or if the package has changed versionFile="${cfg.dataDir}/src-version" - if [[ $(cat "$versionFile" 2>/dev/null) != ${pkg} ]]; then + version=$(cat "$versionFile" 2>/dev/null || echo 0) + + if [[ $version != ${pkg.version} ]]; then ${pkg}/bin/paperless-ngx migrate - echo ${pkg} > "$versionFile" + + # Parse old version string format for backwards compatibility + version=$(echo "$version" | grep -ohP '[^-]+$') + + versionLessThan() { + target=$1 + [[ $({ echo "$version"; echo "$target"; } | sort -V | head -1) != "$target" ]] + } + + if versionLessThan 1.12.0; then + # Reindex documents as mentioned in https://github.com/paperless-ngx/paperless-ngx/releases/tag/v1.12.1 + echo "Reindexing documents, to allow searching old comments. Required after the 1.12.x upgrade." + ${pkg}/bin/paperless-ngx document_index reindex + fi + + echo ${pkg.version} > "$versionFile" fi '' + optionalString (cfg.passwordFile != null) '' |