Merge lp:~michael-sheldon/thumbnailer/fix-1499341 into lp:thumbnailer

Proposed by Michael Sheldon
Status: Superseded
Proposed branch: lp:~michael-sheldon/thumbnailer/fix-1499341
Merge into: lp:thumbnailer
Diff against target: 33 lines (+23/-0)
1 file modified
src/thumbnailer.cpp (+23/-0)
To merge this branch: bzr merge lp:~michael-sheldon/thumbnailer/fix-1499341
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+272373@code.launchpad.net

This proposal has been superseded by a proposal from 2015-09-25.

Commit message

Fall back to full content type detector if the fast detector fails to return anything useful (e.g. because a file doesn't have an extension)

Description of the change

Fall back to full content type detector if the fast detector fails to return anything useful (e.g. because a file doesn't have an extension)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Thank you for the fix, much appreciated!

review: Approve
Revision history for this message
Michi Henning (michihenning) wrote :

Oops, I just realized: this is targeted at trunk, but should be targeted at devel instead. Could you re-target please?

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/thumbnailer.cpp'
2--- src/thumbnailer.cpp 2015-09-15 09:37:17 +0000
3+++ src/thumbnailer.cpp 2015-09-25 11:31:37 +0000
4@@ -565,6 +565,29 @@
5 return ImageData(FetchStatus::error, Location::local); // LCOV_EXCL_LINE
6 }
7
8+ if (content_type == "application/octet-stream") {
9+ // The FAST_CONTENT_TYPE detector will return 'application/octet-stream'
10+ // for all files without an extension (as it only uses the extension to
11+ // determine file type), in these cases we fall back to the full content
12+ // type detector.
13+ gobj_ptr<GFileInfo> full_info(g_file_query_info(file.get(), G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
14+ G_FILE_QUERY_INFO_NONE,
15+ /* cancellable */ NULL,
16+ /* error */ NULL));
17+
18+ if (!full_info)
19+ {
20+ return ImageData(FetchStatus::error, Location::local); // LCOV_EXCL_LINE
21+ }
22+
23+ content_type = g_file_info_get_attribute_string(full_info.get(), G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
24+ if (content_type.empty())
25+ {
26+ return ImageData(FetchStatus::error, Location::local); // LCOV_EXCL_LINE
27+ }
28+
29+ }
30+
31 // Call the appropriate image extractor and return the image data as JPEG (not scaled).
32 // We indicate that full-size images are to be cached only for audio and video files,
33 // for which extraction is expensive. For local images, we don't cache full size.

Subscribers

People subscribed via source and target branches

to all changes: