mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
6022 fix for summarization of files when no textextractor is found
This commit is contained in:
parent
8949600257
commit
f75e02b739
@ -291,13 +291,21 @@ class FileSearch {
|
|||||||
* @return The beginning of text from the specified AbstractFile.
|
* @return The beginning of text from the specified AbstractFile.
|
||||||
*/
|
*/
|
||||||
private static String getFirstLines(AbstractFile file) {
|
private static String getFirstLines(AbstractFile file) {
|
||||||
try (Reader reader = TextExtractorFactory.getExtractor(file, null).getReader()) {
|
TextExtractor extractor;
|
||||||
|
try {
|
||||||
|
extractor = TextExtractorFactory.getExtractor(file, null);
|
||||||
|
} catch (TextExtractorFactory.NoTextExtractorFound ignored) {
|
||||||
|
//no extractor found, use Strings Extractor
|
||||||
|
extractor = TextExtractorFactory.getStringsExtractor(file, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (Reader reader = extractor.getReader()) {
|
||||||
char[] cbuf = new char[PREVIEW_SIZE];
|
char[] cbuf = new char[PREVIEW_SIZE];
|
||||||
reader.read(cbuf, 0, PREVIEW_SIZE);
|
reader.read(cbuf, 0, PREVIEW_SIZE);
|
||||||
return new String(cbuf);
|
return new String(cbuf);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
return Bundle.FileSearch_documentSummary_noBytes();
|
return Bundle.FileSearch_documentSummary_noBytes();
|
||||||
} catch (TextExtractorFactory.NoTextExtractorFound | TextExtractor.InitReaderException ex) {
|
} catch (TextExtractor.InitReaderException ex) {
|
||||||
return Bundle.FileSearch_documentSummary_noPreview();
|
return Bundle.FileSearch_documentSummary_noPreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user