diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-09-23 09:36:45 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-09-23 09:36:45 +0200 |
commit | 566dc060676b41e1e58a446b7dcc4159e242fee6 (patch) | |
tree | 6eaeba1cf78d3f03b8a1d5bfa998eb104ca47425 /src/photos/PhotoFileSniffer.vala | |
parent | 4ea2cc3bd4a7d9b1c54a9d33e6a1cf82e7c8c21d (diff) |
Imported Upstream version 0.20.0upstream/0.20.0
Diffstat (limited to 'src/photos/PhotoFileSniffer.vala')
-rw-r--r-- | src/photos/PhotoFileSniffer.vala | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/photos/PhotoFileSniffer.vala b/src/photos/PhotoFileSniffer.vala index 8bd6711..3f65ac2 100644 --- a/src/photos/PhotoFileSniffer.vala +++ b/src/photos/PhotoFileSniffer.vala @@ -46,7 +46,7 @@ public abstract class PhotoFileSniffer { calc_md5 = (options & Options.NO_MD5) == 0; } - public abstract DetectedPhotoInformation? sniff() throws Error; + public abstract DetectedPhotoInformation? sniff(out bool is_corrupted) throws Error; } // @@ -62,6 +62,7 @@ public class PhotoFileInterrogator { private File file; private PhotoFileSniffer.Options options; private DetectedPhotoInformation? detected = null; + private bool is_photo_corrupted = false; public PhotoFileInterrogator(File file, PhotoFileSniffer.Options options = PhotoFileSniffer.Options.GET_ALL) { @@ -75,14 +76,27 @@ public class PhotoFileInterrogator { return detected; } + // Call after interrogate(). + public bool get_is_photo_corrupted() { + return is_photo_corrupted; + } + public void interrogate() throws Error { foreach (PhotoFileFormat file_format in PhotoFileFormat.get_supported()) { PhotoFileSniffer sniffer = file_format.create_sniffer(file, options); - detected = sniffer.sniff(); - if (detected != null) { + + bool is_corrupted; + detected = sniffer.sniff(out is_corrupted); + if (detected != null && !is_corrupted) { assert(detected.file_format == file_format); break; + } else if (is_corrupted) { + message("Sniffing halted for %s: potentially corrupted image file", file.get_path()); + is_photo_corrupted = true; + detected = null; + + break; } } } |