8000 feat(documents): fetch anytopdf 0.4.0 by adeelahmad · Pull Request #220 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version

- **anytopdf can make Lens's PDFs.** Settings › Documents › Make PDFs with anytopdf. On `auto` (the default) nothing
changes unless anytopdf is here: then it reads the emails, web pages and text a server without Chromium couldn't.
Choose "For every document and image" and Lens downloads anytopdf 0.3.0 (checked against its release checksum);
Choose "For every document and image" and Lens downloads anytopdf 0.4.0 (checked against its release checksum);
it then also reads images, flattening a photographed page before OCR. Or set a conversion node, another machine
running `anytopdf queue serve`, and a small server reads Word, PowerPoint and spreadsheet files too
([anytopdf](docs/configuration.md#anytopdf)).
Expand Down
4 changes: 2 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ Set at startup only (the config file; the web app can't choose what the server r
[anytopdf](https://github.com/adeelahmad/anytopdf-rs) (MIT or Apache-2.0) is Lens's sister project: one static program
that makes documents, photos and media into searchable PDFs. Lens uses it as a converter, two ways:

- **Here.** With `documents.converter` set to `anytopdf`, Lens downloads release 0.3.0 for this machine on first use
- **Here.** With `documents.converter` set to `anytopdf`, Lens downloads release 0.4.0 for this machine on first use
(Linux x86-64 and arm64, macOS), checks it against the release's checksum and keeps only the program in
`data_dir/models/anytopdf-0.3.0/`. It makes the PDF of text, Markdown, web pages and emails from the same cleaned page
`data_dir/models/anytopdf-0.4.0/`. It makes the PDF of text, Markdown, web pages and emails from the same cleaned page
Lens would print with Chromium, so a server without Chromium reads them, and it reads images too: a photographed page
is found, straightened and flattened before OCR. Office files still need LibreOffice beside it.
- **On a conversion node.** With `documents.anytopdf_url` and its token set, every conversion goes to that machine as
Expand Down
10 changes: 5 additions & 5 deletions fastapi_backend/app/domain/anytopdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@

from . import netguard

VERSION = "0.3.0"
VERSION = "0.4.0"
RELEASES = "https://github.com/adeelahmad/anytopdf-rs/releases/download"
# the release archives Lens fetches, by (system, machine), with the sha256 its release published (SHA256SUMS)
ARCHIVES = {
("Linux", "x86_64"): ("x86_64-unknown-linux-musl", "2a789bf099cd14b5f68a147b44170d3f243299565b09b93b3a3329811a2492c0"),
("Linux", "aarch64"): ("aarch64-unknown-linux-musl", "9c6cc307a3e6dc7e7e44c390176ce62e7b77ebad640ea74c569272104a79f6dd"),
("Darwin", "x86_64"): ("x86_64-apple-darwin", "71b9170b75ac6b1783e91f15aaef9fba826d0bda5af7dbb6bbc0efcc9445f2bc"),
("Darwin", "arm64"): ("aarch64-apple-darwin", "29751b5a916a328cafdad52af19a6415a9b72c36ddc8784c8c11bbd936d435c3"),
("Linux", "x86_64"): ("x86_64-unknown-linux-musl", "6f112cb8a961734dee5dbe32dc52418fb1dae59a13bbd7157e9cf03b11d98d1a"),
("Linux", "aarch64"): ("aarch64-unknown-linux-musl", "2478227d025b57e83df919de8eac1e413769a477ec55324ef461afdbe3e4e08f"),
("Darwin", "x86_64"): ("x86_64-apple-darwin", "9226586135d8bd49bee9b7a57e39af6913f39c06d31c3187856cd53a939d0e81"),
("Darwin", "arm64"): ("aarch64-apple-darwin", "6b0a803ab4cc1cf8cba3bb21adb874df5a9bea521b5149773b0f5c7ec7248cc5"),
}
MACHINES = {"amd64": "x86_64", "arm64": "arm64", "aarch64": "aarch64"}
# its search layer: the document's own text, not the dates, colours and places it would add
Expand Down
8 changes: 4 additions & 4 deletions fastapi_backend/tests/api/test_anytopdf.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ def test_it_is_fetched_when_asked_for(cfg, monkeypatch, tmp_path):
assert not comp.needed(cfg, {}) # a node does the work

# the release archive for this machine, checked against its checksum; only the program is kept
assert anytopdf.archive("Linux", "aarch64")[0] == "anytopdf-0.3.0-aarch64-unknown-linux-musl.tar.gz"
assert anytopdf.archive("Darwin", "arm64")[0] == "anytopdf-0.3.0-aarch64-apple-darwin.tar.gz"
assert anytopdf.archive("Linux", "aarch64")[0] == "anytopdf-0.4.0-aarch64-unknown-linux-musl.tar.gz"
assert anytopdf.archive("Darwin", "arm64")[0] == "anytopdf-0.4.0-aarch64-apple-darwin.tar.gz"
assert anytopdf.archive("Windows", "AMD64") is None
name = "anytopdf-0.3.0-x86_64-unknown-linux-musl"
name = "anytopdf-0.4.0-x86_64-unknown-linux-musl"
(tmp_path / name / "plugins").mkdir(parents=True)
(tmp_path / name / "anytopdf").write_bytes(b"#!/bin/sh\necho anytopdf 0.3.0\n")
(tmp_path / name / "anytopdf").write_bytes(b"#!/bin/sh\necho anytopdf 0.4.0\n")
(tmp_path / name / "plugins" / "anytopdf-plugin-faces").write_bytes(b"x")
with tarfile.open(tmp_path / f"{name}.tar.gz", "w:gz") as t:
t.add(tmp_path / name, arcname=name)
Expand Down
2 changes: 1 addition & 1 deletion fastapi_backend/tests/fake_anytopdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

args = sys.argv[1:]
if args == ["--version"]:
print("anytopdf 0.3.0")
print("anytopdf 0.4.0")
sys.exit(0)
with open(@LOG@, "a") as f:
f.write(json.dumps({"args": args, "proxy": os.environ.get("https_proxy"), "anytopdf_env": sorted(k for k in os.environ if k.startswith("ANYTOPDF_"))}) + "\n")
Expand Down
Loading
0