Repository navigation
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 4 critical |
🟢 Metrics 106 complexity
Metric Results Complexity 106
🟢 Coverage 80.70% diff coverage
Metric Results Coverage variation Report missing for 413082e1 Diff coverage ✅ 80.70% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (413082e) Report Missing Report Missing Report Missing Head commit (4fb37e9) 93639 26999 28.83% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#3332) 228 184 80.70% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
4043342 to
47a7136
Compare
There was a problem hiding this comment.
Pull request overview
Adds embedded JPEG preview extraction for TIFF-based camera RAW thumbnails.
Changes:
- Adds RAW MIME routing and documentation.
- Implements bounded TIFF/BigTIFF preview extraction with EXIF orientation.
- Adds extraction, hardening, orientation, and decoder tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
services/thumbnails/README.md |
Documents RAW thumbnail support. |
pkg/thumbnail/mimetypes.go |
Registers RAW MIME types. |
pkg/thumbnail/mimetypes_vips.go |
Registers RAW types for VIPS. |
pkg/service/grpc/v0/service.go |
Handles missing RAW previews quietly. |
pkg/preprocessor/rawtiff.go |
Extracts and validates embedded JPEGs. |
pkg/preprocessor/rawtiff_test.go |
Tests RAW extraction and hardening. |
pkg/preprocessor/preprocessor.go |
Routes RAW types to the decoder. |
pkg/preprocessor/preprocessor_test.go |
Tests RAW MIME routing. |
pkg/errors/error.go |
Adds the missing-preview error. |
Suppressed comments (4)
services/thumbnails/pkg/preprocessor/rawtiff.go:142
- This bounds check can overflow before it checks the untrusted BigTIFF offset. For example, a first-IFD offset near
MaxUint64makesifdOffset + 8wrap belowdlen, after which the slice on line 147 panics. Use subtraction-based bounds checks (or explicit overflow checks) before slicing so a crafted raw upload cannot crash the service.
if ifdOffset == 0 || ifdOffset+uint64(countSize) > dlen {
services/thumbnails/pkg/preprocessor/rawtiff.go:204
arrayOffsetis file-controlled, so both additions here can wrap. With an offset nearMaxUint64,pos + offWbecomes a small number and passes the check, thendata[pos:]panics. Reject offsets using subtraction/overflow-safe bounds checks before reading the SubIFD array.
pos := arrayOffset + j*uint64(offW)
if pos+uint64(offW) > dlen || len(queue) >= maxIFDs {
services/thumbnails/pkg/preprocessor/rawtiff.go:117
- BigTIFF widens the entry value field, but accepted
LONGvalues are still 4 bytes. Reading every BigTIFF field asUint64misreads a big-endian inline LONG asvalue << 32; the 8-byte stride used later also misreads LONG SubIFD lists. Decode values and array strides fromtyp, not only from the container, otherwise valid big-endian BigTIFF/DNG previews are missed.
// readOff reads a 4- or 8-byte offset/value depending on the container.
readOff := func(b []byte) uint64 {
if bigTiff {
return order.Uint64(b[:8])
}
return uint64(order.Uint32(b[:4]))
}
services/thumbnails/pkg/preprocessor/rawtiff.go:261
- Returning true immediately on a DCT SOF marker does not establish that the JPEG is renderable: the SOF length may be invalid, or the stream may be truncated before any scan. Because extraction keeps only the largest candidate, a larger corrupt candidate can then mask a valid smaller preview and make
Convertfail instead of falling back. Validate enough of the stream to reject malformed candidates, or try candidates in size order until one decodes.
case 0xc0, 0xc1, 0xc2: // baseline, extended sequential, progressive
return true
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… width Review of #3332 surfaced two BigTIFF-only defects in the embedded-preview walker (attacker-controlled input): - 64-bit IFD and SubIFD-array offsets were bounds-checked with `off + n > len`, which wraps for a crafted offset near 2^64, bypassing the guard and slicing out of range -> panic (recovered by the framework into a 500 + stack log on every crafted request, defeating the no-panic goal). Now overflow-safe. - a tag value was always read as an 8-byte Uint64 in BigTIFF; a LONG (4-byte) offset in a big-endian BigTIFF was thereby shifted. Read it at its declared type width instead. Adds tests for the overflow paths (assert ErrNoImageFromRawFile, no panic), the big-endian LONG offset, and strengthens the truncation test to assert the error. Trims a few over-long comments.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (3)
services/thumbnails/pkg/preprocessor/rawtiff.go:201
- SubIFD pointers may use TIFF type IFD (13) and BigTIFF type IFD8 (18), but
isLongTypeaccepts only LONG/LONG8, so valid preview-bearing SubIFDs using the pointer-specific types are skipped. Extend the type-width/read helpers to accept IFD/IFD8; otherwise such DNG/BigTIFF files incorrectly report no preview.
case tiffTagSubIFDs:
if !isLongType(typ, bigTiff) {
continue
services/thumbnails/pkg/preprocessor/rawtiff.go:221
- In BigTIFF the value-or-offset field is 8 bytes, so a SubIFDs value containing exactly two LONG offsets is stored inline. Treating every
count > 1value as an array pointer interprets those two offsets as one bogus uint64 file offset and misses both preview IFDs.
// count > 1: the value field points at an array of count offsets,
// each of the tag's own width (LONG 4B, LONG8 8B)
arrayOffset := readOff(entry[valAt:])
services/thumbnails/pkg/preprocessor/rawtiff.go:196
- Valid TIFF encodes both
StripOffsetsandStripByteCountsas either SHORT or LONG, but these guards reject SHORT. A raw file whose only embedded JPEG is a single strip using SHORT values will therefore produceErrNoImageFromRawFile. Please read scalar SHORT values as 16-bit values for both tags (and add a regression case).
if isLongType(typ, bigTiff) && count == 1 {
stripOffset = readVal(entry[valAt:], typ)
}
case tiffTagStripByteCounts:
if isLongType(typ, bigTiff) && count == 1 {
rhafer
left a comment
There was a problem hiding this comment.
As much as I'd like to have previews for my raw images (DNG in my case), I'd really prefer us to get not into the business of creating/maintaining a TIFF parser (even with the help of AI). Especially given the experience with the recent security flaws in libvips (which were also TIFF related).
I see your PR to evanoberholster/imagemeta got merged. So using that might help.
And then there is #1128 which suggests to replace the embedded thumbnailer with something like https://github.com/cshum/imagor for better scalability and broader images format support. (Unfortunately AFAICS imagor does not extract the embedded previews though, but tries to render the rawdata)
I am not giving this a 👎 , but I think we should not merge without further consideration.
@butonic any thoughts on this?
|
Thanks for the considerate review, @rhafer :) One more idea - tika has a concept of embedded files. I've already implemented audio artwork support using that mechanism. I mainly wanted both extractions to implement the thumbnails relationship on driveItems, but thinking about it in the context of your concerns and the possible move to imagor it makes me think: We could pipe audio files and raw images from the thumbnails service to tika for preview extraction. Having implemented the original audio artwork thumbnails feature, I can say I'd happily drop the built in support for something more maintained like tika. Moreover, we'd use the same mechanism as in the search service and the supported file formats and features would always align (unlike with a completely different code path like right now). Thoughts? |
|
I liked my idea so much, that I immediately wanted to give it a spin 😁 +395 now, the built in approach had +936 - I'm satisfied :D What do you think? |
|
Tika PR is merged 🙂 |
4ba384f to
0d0a6a6
Compare
0d0a6a6 to
9ac2bc4
Compare
05072f1 to
92a183b
Compare
872de5f to
c10390f
Compare
Every file the built-in converters cannot render goes to /unpack/thumbnail (Tika 4.1) and comes back with the image Tika marks as its thumbnail.
Tika merged the thumbnail catalog preset and ThumbnailUnpackSelector (TIKA-4856): PUT /unpack/preset/thumbnail returns exactly the one raster image a client would show for the document, a stored thumbnail, the rendering of a metafile thumbnail, or the rendered first page. The client-side selection over /unpack/all (embedded-resource-type marks, metafile renderings, id-path matching) moves to the server; the preset zip carries one image without metadata sidecars, so the entry's extension names the type and the bytes break the tie. The preset has to be active, so this needs a Tika 4.2.0 or newer started with TIKA_PRESETS=thumbnail, and a 404 says so.
PUT /unpack/preset/thumbnail answers 404 unless the thumbnail catalog preset is active, and the thumbnailer then finds no thumbnail for any document. TIKA_PRESETS=thumbnail activates it and needs Tika 4.2.0, so the acceptance stack and the example deployment follow the snapshot image until the release is out. The deployment also reads the shared OC_TIKA_URL so the thumbnailer uses the Tika that is already there.
The cache key is derived from configuration again: a thumbnail is written in the type the file's own type maps to, so the answer no longer depends on what Tika hands back and needs no placeholder in the key. Which types Tika gets is decided in one place now. An image type goes to Tika only when a deployment names it, because the generator behind the URL may read it itself, which also lets a raw photo reach Tika at all.
What an extractor makes of a file does not depend on the size that was asked for, so it is kept under one key per file and read before the file is even downloaded. An empty entry says the file carries nothing, which keeps the next size from asking Tika again; a failed extraction is not remembered. The file cache now replaces what a key holds, as the other two backends already did, because an entry whose value can change has to be replaceable.
Both answer with the same image for the same file, only the package differs, and a 4.1.x server has no preview for erf, orf and rw2. The 404 now names both ways to activate the preset.
The catch-all was hidden in NewTika, so neither the yaml nor the env documentation showed it. It is a plain default now, like the CORS origins, and an empty list means what it says: nothing goes to Tika, and the server behind OC_TIKA_URL stays the search service's.
The type decides which parser reads the file, so a raw photo that Tika only detected as a plain tiff is parsed as a tiff and its embedded preview is never found. No shipped format needs the hint, which is why the knob reads like dead code and has to say that it is not.
ForType decided by the name of the type: anything starting with image/ was handed to the generator, and no converter meant handing it over as well. A camera raw is an image by that rule, so it travelled to a generator that cannot read it, and an announced pdf travelled there too. It now asks in one order who claims the file: a type the Tika list names, an image the generator reads, a converter here, a catch-all, and otherwise nobody, which answers 404 before the file is read at all. The Tika list carries the formats a release serves a thumbnail for, the camera raws among them, and the default config hands it in, so an empty list still means nothing goes to Tika and a shared server stays the search service's. OC_TIKA_ADDITIONAL_THUMBNAIL_MIME_TYPES adds to it.
…eilings in writing The description said an empty list leaves the built-in list in place, which is what an unset variable does; an explicitly empty one sends nothing. And a ladder that reaches past the generator's output ceiling asks for a box the generator refuses, which nothing checks for us, so the thumbnails README says it.
A named Tika type goes to Tika, then the built-in converters, then images to the generator, then the rest to Tika under "*" or to the generator. "*" never sends an image, which only moved the file to come back empty, and an announced type without a converter reaches the generator again, as it does on main since the generator pass-through.
|
|
||
| So `*` never sends an image: images belong to the generator, and sending one to Tika would only move the file. An image type that only Tika can read has to be named in the Tika list. Announcing a type in `OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES` and sending it to Tika are separate decisions: the announcement is what `oc:has-preview` reports, the Tika list says who makes the image. Naming a type also restricts Tika to the named ones, so a deployment that sends raw photos to Tika has to name the document types it wants from Tika as well, and an empty list sends nothing at all, which leaves the Tika server to the search service alone. The thumbnail is written in the type the **file's** own type maps to (`OC_THUMBNAILS_ADDITIONAL_OUTPUT_TYPES`), not in whatever type Tika hands back, so the answer is the same before and after a cache hit. That is also why a windows binary is mapped to `image/png` by default: the icon Tika reads out of it carries transparency that a JPEG would flatten onto black. | ||
|
|
||
| Generated thumbnails are cached by the webdav service itself. The cache backend defaults to `file`, storing entries under `$OC_BASE_DATA_PATH/thumbnails/cache` (override with `WEBDAV_THUMBNAILS_CACHE_BACKEND` and `WEBDAV_THUMBNAILS_CACHE_DIR`). Use the `s3` backend when running multiple instances behind a load balancer so they share one cache. A backend nobody can serve, an unknown name or an `s3` backend without bucket, region and credentials, fails at startup instead of serving without a cache, as long as previews are enabled. A service that is not AWS needs `WEBDAV_THUMBNAILS_CACHE_S3_ENDPOINT` too, and it is always addressed over https. The `memory` backend is bounded and drops its oldest entries; `none` disables caching on purpose. The cache also keeps the image an extractor made of a file, under one entry per file, so a second size does not extract again and a file that carries no image is only asked once. Nothing expires: a changed file is a new entry because the key carries its checksum, but an extractor that learns to read a format it could not read before does not reach the files it already answered for. After such an upgrade, an Apache Tika release among them, empty the cache (`WEBDAV_THUMBNAILS_CACHE_DIR`, or the bucket) to have them asked again. |
There was a problem hiding this comment.
This is quite the wall of dense text. This last "caching" paragraph especially caould proably be use subsections for the different options.
| When `OC_TIKA_URL` (or `WEBDAV_TIKA_URL`) is set, an Apache Tika server (4.2.0 or newer) supplies the preview image for documents, raw photos, audio cover art and other types. Which types go there is a list, and the default is the formats a Tika release serves a thumbnail for: documents, ebooks, office and iWork files, audio cover art and the camera raws. `OC_TIKA_THUMBNAIL_MIME_TYPES` (or `WEBDAV_TIKA_THUMBNAIL_MIME_TYPES`) replaces that list, `OC_TIKA_ADDITIONAL_THUMBNAIL_MIME_TYPES` adds to it, a single `*` in either sends every type that nothing else claims, and an empty list sends nothing at all, which leaves a Tika server shared with the search service to the search service alone. An entry like `image/x-nikon-nef:image/x-raw-nikon` maps a type to the one Tika knows the format by. Tika takes a declared type only when it refines what it detected itself, so an entry pins the leaf type its detector left at the parent, a raw photo it only read as a plain tiff. The type decides which parser reads the file: a raw read as a tiff is parsed as a tiff, its maker notes stay unread, and the embedded preview a thumbnail would be made of is never found. The formats in the default list are detected down to the leaf type, so none of them needs the hint, and it is there for the next format whose detection stops one level short. The webdav service calls `PUT /unpack/preset/thumbnail`, so the Tika server has to run with the `thumbnail` catalog preset active: start it with `TIKA_PRESETS=thumbnail`, a comma separated list of the presets to activate. Without Tika, audio cover art and GeoGebra thumbnails are still extracted by the webdav service itself; those built-in extractors are deprecated. A type Tika takes is attempted even when `OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES` does not announce it, so a direct request can get a preview that a listing reports as absent. Who gets a file is decided in one order, first match wins, and every type has exactly one taker: | ||
|
|
||
| 1. a type the Tika list names goes to Tika, an image too, which is why the camera raws are named there: reva types them as images and no generator reads them | ||
| 2. text, audio and GeoGebra go to the built-in extractors |
There was a problem hiding this comment.
I wonder if we should drop the in process extractors ... I really don't want to look at bytes in the webdav service. The idea of the thumbnails service is that it is a drop in replacement for imagor in case there is a security issue in vips, so there are at least some thumbnails. Production deployments can then just deploy the thumbnails service standalone as a replacement for imagor. maybe we can move the built in extractors to a tika drop in as well? or just add a handler to the thumbnails service that acts like tika? That way we can disable the built in extractors when tika is used and use a fallback otherwise.
@dschmidt what do you think?
There was a problem hiding this comment.
Yes, fully agree with getting rid of the in process extractors.
To be honest, I would just like to drop these code paths from OpenCloud.
Then if we switch off Tika or just never enable it we/users lose GeoGebra and Audio thumbnails - I think that's really not too bad. I love them as a feature, but it really doesn't stop me from working with OpenCloud if I don't have it - especially not temporarily - so I think it's reasonable to say: if you want those and 30 other preview formats, just use Tika.
What I can do tho is to check Tika turned off doesn't cache "no preview" permanently.
There was a problem hiding this comment.
If you insist, I would move the in process extractors to the thumbnails service instead of to a new service, but honestly I don't think it's worth the effort at all.
And same as the Imagor refactor needing an Imagor URL in a distributed setup, this would still be a breaking change. I'd argue if we do a breaking change anyhow, let's get rid of it completely.
If you like I can try to upstream the text rendering to Tika as well, so we get rid of that too.
| The webdav service provides various `GET` endpoints to get the thumbnails of a file in authenticated and unauthenticated contexts. It also provides thumbnails for spaces on different endpoints. | ||
|
|
||
| Generated thumbnails are cached by the webdav service itself. The cache backend defaults to `file`, storing entries under `$OC_BASE_DATA_PATH/thumbnails/cache` (override with `WEBDAV_THUMBNAILS_CACHE_BACKEND` and `WEBDAV_THUMBNAILS_CACHE_DIR`). Use the `s3` backend when running multiple instances behind a load balancer so they share one cache. A backend nobody can serve, an unknown name or an `s3` backend without bucket, region and credentials, fails at startup instead of serving without a cache, as long as previews are enabled. A service that is not AWS needs `WEBDAV_THUMBNAILS_CACHE_S3_ENDPOINT` too, and it is always addressed over https. The `memory` backend is bounded and drops its oldest entries; `none` disables caching on purpose. | ||
| When `OC_TIKA_URL` (or `WEBDAV_TIKA_URL`) is set, an Apache Tika server (4.2.0 or newer) supplies the preview image for documents, raw photos, audio cover art and other types. Which types go there is a list, and the default is the formats a Tika release serves a thumbnail for: documents, ebooks, office and iWork files, audio cover art and the camera raws. `OC_TIKA_THUMBNAIL_MIME_TYPES` (or `WEBDAV_TIKA_THUMBNAIL_MIME_TYPES`) replaces that list, `OC_TIKA_ADDITIONAL_THUMBNAIL_MIME_TYPES` adds to it, a single `*` in either sends every type that nothing else claims, and an empty list sends nothing at all, which leaves a Tika server shared with the search service to the search service alone. An entry like `image/x-nikon-nef:image/x-raw-nikon` maps a type to the one Tika knows the format by. Tika takes a declared type only when it refines what it detected itself, so an entry pins the leaf type its detector left at the parent, a raw photo it only read as a plain tiff. The type decides which parser reads the file: a raw read as a tiff is parsed as a tiff, its maker notes stay unread, and the embedded preview a thumbnail would be made of is never found. The formats in the default list are detected down to the leaf type, so none of them needs the hint, and it is there for the next format whose detection stops one level short. The webdav service calls `PUT /unpack/preset/thumbnail`, so the Tika server has to run with the `thumbnail` catalog preset active: start it with `TIKA_PRESETS=thumbnail`, a comma separated list of the presets to activate. Without Tika, audio cover art and GeoGebra thumbnails are still extracted by the webdav service itself; those built-in extractors are deprecated. A type Tika takes is attempted even when `OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES` does not announce it, so a direct request can get a preview that a listing reports as absent. Who gets a file is decided in one order, first match wins, and every type has exactly one taker: |
There was a problem hiding this comment.
wow the logic makes my head hurt ... can you document this with examples for typical scenarios?
Thumbnails for everything webdav should not decode in-process: raw camera images, audio cover art, the first page of a pdf, the metafile an office document carries, the icon of a windows binary. One generic step, no format-specific code.
Routing, typical setups and the cache are documented in the rendered webdav README.
webdav PUTs the file to Tika's
/unpack/preset/thumbnailand hands the image on undecoded. The image is taken out of the answer by its type, not by what the package calls its own files, which Tika renamed once already (TIKA-4971).Extraction happens once per file, not once per size. What an extractor makes of a file does not depend on the size that was asked for, so the extracted image is cached under one key per file, its checksum, and that entry is read before the file is even downloaded. The first requested size pays for the download and the extraction, every other size and every later request is scaled from the cached image, and an empty entry records that a file carries no image at all so Tika is never asked for it twice. The thumbnails themselves keep their own entry per size as before.
Tika has to run with the
thumbnailcatalog preset active, otherwise the route answers 404:That needs Tika 4.2.0 or newer. CI and the example deployment run
apache/tika:4.2.0-SNAPSHOT-fulluntil it is out.With a Tika before 4.2.0 the same route is served once the preset is activated in its config file, which is what it takes there:
{ "server": { "port": 9998, "host": "0.0.0.0" }, "presets": { "thumbnail": true } }Two size limits sit in front of the extraction, and they have to agree.
WEBDAV_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE(50 MB by default) gates every source before it is downloaded, the Tika path included, so an audiobook or a large PDF answers403until it is raised, although Tika would have had no trouble with it. Tika itself refuses a request body overmaxRequestSizeBytes(1 GiB by default) with413, which webdav reports as404and does not remember, so every request for such a file streams it to Tika again. Until TIKA-5025 (apache/tika#3519) lands, that limit can only be raised in Tika's config file, where theserverblock is then required:{ "server": { "port": 9998, "host": "0.0.0.0", "maxRequestSizeBytes": 4294967296 }, "presets": { "thumbnail": true } }Measured with three MPEG-4 audiobooks of 0.75, 1.07 and 1.46 GB: with the webdav limit at 2 GB and Tika's at 4 GiB all three give up their cover in 4 to 8 seconds, every later request comes from the cache.
Measured against 4.1.0 and a current 4.2.0 build: the same image for the same file, for documents, audio cover art, ebooks and raw photos, only the package it arrives in differs (4.2.0 wraps it in
datapackage.json,rmeta.jsonand anunpacked/directory), and this service takes the image by its type, not by its name. What 4.1.0 does not have are the raw formats added after it, an Epson.erf, an Olympus.orfand a Panasonic.rw2carry no preview there and answer404.Which types go to Tika is a list, and the default is the formats a release serves a thumbnail for: documents, ebooks, office and iWork files, GeoGebra, audio cover art, windows binaries and the camera raws reva knows.
OC_TIKA_THUMBNAIL_MIME_TYPESreplaces that list,OC_TIKA_ADDITIONAL_THUMBNAIL_MIME_TYPESadds to it, a single*in either takes every type nothing else claims, and an empty list sends nothing, which leaves a Tika shared with the search service to the search service alone.The camera raws are in the list for a reason: reva types them as images, and every type has exactly one taker, the first that applies. A type the Tika list names goes to Tika, an image too; then the built-in extractors take text, audio and GeoGebra; then an image goes to the generator as it is; then a
*in the Tika list takes what is left; and anything else goes to the generator as it is, which answers whether it can read it (as it does on main since #3884). So*never sends an image: images belong to the generator, and sending one to Tika would only move the file. An image type only Tika can read has to be named in the Tika list. Announcing a type inOC_THUMBNAILS_ADDITIONAL_SOURCE_TYPESand naming it in the Tika list are separate decisions: the first is whatoc:has-previewreports, the second says who makes the image.On the webdav side this is the whole configuration:
OC_TIKA_URL=http://127.0.0.1:9996 # only decides what oc:has-preview announces, never what is extracted: OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES=application/epub+zip,application/msword,application/octet-stream,\ application/pdf,application/vnd.apple.numbers,application/vnd.apple.pages,\ application/vnd.geogebra.file,application/vnd.geogebra.slides,application/vnd.ms-powerpoint,\ application/vnd.ms-xpsdocument,application/vnd.oasis.opendocument.presentation,\ application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.text,\ application/vnd.openxmlformats-officedocument.presentationml.presentation,\ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,\ application/vnd.openxmlformats-officedocument.wordprocessingml.document,\ application/x-msdownload,audio/mpeg,audio/ogg,audio/x-flac,audio/x-m4a,\ image/x-adobe-dng,image/x-canon-cr2,image/x-epson-erf,image/x-icon,image/x-nikon-nef,\ image/x-olympus-orf,image/x-pentax-pef,image/x-sony-arw,image/x-sony-sr2OC_TIKA_URLalone gets the previews, the default list covers the formats; what the list above still buys is the announcement, until #3210 answersoc:has-previewfrom the index. Measured over the corpus (Tika's test documents, raw.pixls.us camera raws, generated audio and video), 37 of 40 files give up an image, the three that do not being a README, an xls whose thumbnail sits in an attachment and an ico, which the generator reads itself.application/octet-streamis in the announcement list above because reva reports it for iWork keynotes and, until the bumps land, for.m4baudiobooks and.azw3ebooks; it is deliberately not in the Tika list, so those need reva to learn their types (opencloud-eu/reva#905 did it for RW2, opencloud-eu/reva#965 doesaudio/x-m4bandapplication/vnd.amazon.mobi8-ebook).audio/x-m4bis already in the Tika list here, so the audiobook covers work as soon as the reva bump arrives;.azw3waits for a Tika that extracts Mobipocket covers (TIKA-5026, apache/tika#3520).Icons and windows binaries map to png by default, since the jpeg fallback would turn transparency black. A file that carries no thumbnail answers 404, not 500.
What a client is told it can preview still comes from the static mime list, so these formats are reachable by direct request but not advertised. #3210 answers that from the index and is stacked on top.
Open: the source cache key
Notes from a read of
ed740def, to be done in this PR before it merges. None of them changes the cache interface or the configuration.sourceStorageKeyused the raw checksum and no mime type, whilethumbnailStorageKeyhasheschecksum + "\x00" + mimeType: the checksum comes from a remote PROPFIND on an OCM share and ends up as a path and an object key, and the type picks the extractor, so the same bytes under two types are not the same extraction (a copy ofreport.pdfsaved asreport.txtwould otherwise hand the pdf the text rendering). Both keys now share one prefix function, so they cannot drift apart again (9ee07e9).OC_TIKA_URLmoves audio and GeoGebra from the built-in converters to Tika, and an empty answer from one must not stand in for the other. Each converter names itself (tika,oc-audio,oc-ggs,oc-ggp,oc-text) and the source entry issource-<name>. The empty entry per size is gone: whether a file has an image does not depend on the size, so only the source entry records it (79fe3b2).http.DetectContentType. The type belongs next to the bytes, together with the Tika version below. How is open: a header in the value works the same in every backend, a sibling entry or native metadata (xattrs, S3 object metadata) keep the image a plain file but cost a second read or an interface change. A new key suffix for the source entry keeps any of them additive, old entries are simply not found and extracted once more.rememberSourcealso checkedmaxInputSize, which only kept a source out of the cache when the input limit was set below 8 MB, and then made every further size extract again;maxCachedSourceBytesalone bounds what is kept (4fb37e9).Limitation: the Tika version is not tracked. The key cannot carry it, because the lookup happens before anyone asks Tika which version it is. A file Tika had no preview for (ERF, ORF and RW2 before 4.2) keeps its empty entry after an upgrade until the cache is emptied, as the README says. The fix is to store the extractor's version next to the bytes, so an empty answer from an older version is retried. That fits with storing the content type above, since both need metadata next to the bytes, and is left for a follow-up.
Not for this PR: the input size check in
statSourceruns before the source cache is read, and the converters read the whole file into memory. Both are right for what this PR extracts and would have to change for video, where the master would sit in the cache while the file itself is far above any sensible input limit.