summaryrefslogtreecommitdiff
path: root/src/photos/PhotoFileSniffer.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-23 09:36:56 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-23 09:36:56 +0200
commit8004f1a7ad3cc6a3659517f3374bdf1b63416b24 (patch)
treeb7b82cc6e01cd47d22f660e25508a7d8d555dc89 /src/photos/PhotoFileSniffer.vala
parent28c68a75acac7ac3ce7fb169bc6aa65e16551c53 (diff)
parent566dc060676b41e1e58a446b7dcc4159e242fee6 (diff)
Merge tag 'upstream/0.20.0'
Upstream version 0.20.0
Diffstat (limited to 'src/photos/PhotoFileSniffer.vala')
-rw-r--r--src/photos/PhotoFileSniffer.vala20
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;
}
}
}