Repository: jonaswinkler/paperless-ng

Issue #197: plain text files are not being consumed (OSError: cannot open resource)
Created: 2020-12-27T23:48:48Z
I'm currently evaluating your project and so far, I'm liking it a lot, thank you for providing it!
I just stumbled across an issue with plain text files though. From reading the docs and looking at closed github issues about this topic, I assumed I could just add arbitrary text files and they would show up as documents.
However, when I added my first .txt file, it appears it's stuck somewhere in the consumption process. The logs only show this:
12/27/20, 11:44 PM DEBUG Parsing gitlab-recovery-codes.txt...
12/27/20, 11:44 PM DEBUG Parser: TextDocumentParser based on mime type text/plain
12/27/20, 11:44 PM INFO Consuming gitlab-recovery-codes.txt

No thumbnail was generated. The files content is (as the file name states) a list of gitlab account recovery codes: 10 lines, each one in the format ^[a-f0-9]{16}$
So nothing special I assume
Looking further at the docker logs, they say the file was not found (I added it through the UI, just like a bunch of files before)
23:44:53 [Q] INFO Process-1:1 processing [gitlab-recovery-codes.txt]
INFO 2020-12-27 23:44:53,796 loggers Consuming gitlab-recovery-codes.txt
23:44:54 [Q] ERROR Failed [gitlab-recovery-codes.txt] - cannot open resource : Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django_q/cluster.py", line 436, in worker
    res = f(*task["args"], **task["kwargs"])
  File "/usr/src/paperless/src/documents/tasks.py", line 73, in consume_file
    override_tag_ids=override_tag_ids)
  File "/usr/src/paperless/src/documents/consumer.py", line 135, in try_consume_file
    self.path, mime_type)
  File "/usr/src/paperless/src/documents/parsers.py", line 235, in get_optimised_thumbnail
    thumbnail = self.get_thumbnail(document_path, mime_type)
  File "/usr/src/paperless/src/paperless_text/parsers.py", line 27, in get_thumbnail
    layout_engine=ImageFont.LAYOUT_BASIC)
  File "/usr/local/lib/python3.7/site-packages/PIL/ImageFont.py", line 836, in truetype
    return freetype(font)
  File "/usr/local/lib/python3.7/site-packages/PIL/ImageFont.py", line 833, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/local/lib/python3.7/site-packages/PIL/ImageFont.py", line 194, in __init__
    font, size, index, encoding, layout_engine=layout_engine
OSError: cannot open resource

Any idea what's happening here?

Duplicate issue #207: Font not found for parser_text
Created: 2020-12-29T09:40:23Z
When ingesting a number of csv-files, I saw this error come up:
| 10:29:39 [Q] ERROR Failed [2014-12-01-554047.csv] - cannot open resource : Traceback (most recent call last):
|   File "/usr/local/lib/python3.7/site-packages/django_q/cluster.py", line 436, in worker
|     res = f(*task["args"], **task["kwargs"])
|   File "/usr/src/paperless/src/documents/tasks.py", line 73, in consume_file
|     override_tag_ids=override_tag_ids)
|   File "/usr/src/paperless/src/documents/consumer.py", line 135, in try_consume_file
|     self.path, mime_type)
|   File "/usr/src/paperless/src/documents/parsers.py", line 235, in get_optimised_thumbnail
|     thumbnail = self.get_thumbnail(document_path, mime_type)
|   File "/usr/src/paperless/src/paperless_text/parsers.py", line 27, in get_thumbnail
|     layout_engine=ImageFont.LAYOUT_BASIC)
|   File "/usr/local/lib/python3.7/site-packages/PIL/ImageFont.py", line 836, in truetype
|     return freetype(font)
|   File "/usr/local/lib/python3.7/site-packages/PIL/ImageFont.py", line 833, in freetype
|     return FreeTypeFont(font, size, index, encoding, layout_engine)
|   File "/usr/local/lib/python3.7/site-packages/PIL/ImageFont.py", line 194, in __init__
|     font, size, index, encoding, layout_engine=layout_engine
| OSError: cannot open resource

After investigating, I found that /usr/share/fonts/liberation/LiberationSerif-Regular.ttf was hard-coded as the font, but:
$ docker exec -ti paperless_webserver_1 ls -l /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
ls: cannot access '/usr/share/fonts/liberation/LiberationSerif-Regular.ttf': No such file or directory
Furthermore:
$ docker exec -ti paperless_webserver_1 dpkg -S LiberationSerif-Regular.ttf
fonts-liberation: /usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf
fonts-liberation2: /usr/share/fonts/truetype/liberation2/LiberationSerif-Regular.ttf
So:

the font has disappeared (and/or moved)?
can we make this configurable through paperless.conf?

Closing comment (2020-12-29T11:04:33Z): Duplicate of #197

Sorry, totally correct.