tags 327182 + patch thanks On Thu, Sep 08, 2005 at 02:12:26PM +0200, Filip Van Raemdonck wrote: > On Thu, Sep 08, 2005 at 10:20:24AM +0200, Filip Van Raemdonck wrote: > > > > Trying to import my home directory, f-spot apparently ran into some file > > which it believes not to be a valid PNG image. However, instead of telling > > me so (and which file it is!) it just crashes > > Here's another stack trace, for a TIFF file which isn't one (but f-spot > thinks it is) (the PNG file turned out to be just ASCII text, too):
Attached is a patch which makes f-spot spit out which png or tiff is faulty if it encounters one, combined with another which does not make it crash. Note that neither are simply 'lets get this working' kind of patches: the output filename bits are suboptimal, in that they simply spit wrap up the old exception in a new one which has the bare filename as message; f-spot should probably have it's own BadImage exception type instead. And the don't crash snippet should (IMO) be improved as well, by adding failing images to a list which is presented to the user when the import is done. ("These images were found by f-spot, but could not be read for some reason. You may want to investigate why:") Regards, Filip -- "The only way to get rid of a temptation is to yield to it." -- Oscar Wilde
--- f-spot-0.1.1-old/debian/changelog +++ f-spot-0.1.1/debian/changelog @@ -1,3 +1,10 @@ +f-spot (0.1.1-2.1) unstable; urgency=low + + * For broken PNG and TIFF files, have the traceback include the filename. + * And additionally do not crash but skip the faulty images instead. + + -- Filip Van Raemdonck <[EMAIL PROTECTED]> Wed, 8 Sep 2005 21:04:45 +0200 + f-spot (0.1.1-2) unstable; urgency=low * Andrew Mitchell --- f-spot-0.1.1-old/src/FileImportBackend.cs +++ f-spot-0.1.1/src/FileImportBackend.cs @@ -137,20 +137,25 @@ System.IO.File.Copy (path, dest); path = dest; } - - photo = store.Create (path, out thumbnail); - if (tags != null) { - foreach (Tag t in tags) { - photo.AddTag (t); + try { + photo = store.Create (path, out thumbnail); + + if (tags != null) { + foreach (Tag t in tags) { + photo.AddTag (t); + } + store.Commit(photo); } - store.Commit(photo); - } - - imported_photos.Add (photo); - this.count ++; - count = this.count; + imported_photos.Add (photo); + } catch { + photo = null; + thumbnail = null; + } finally { + this.count ++; + count = this.count; + } return count != file_paths.Count; } --- f-spot-0.1.1-old/src/PngFile.cs +++ f-spot-0.1.1/src/PngFile.cs @@ -8,7 +8,11 @@ { this.path = path; using (System.IO.Stream input = System.IO.File.OpenRead (this.Path)) { - Load (input); + try { + Load (input); + } catch (System.Exception e) { + throw new System.Exception (this.Path, e); + } } } --- f-spot-0.1.1-old/src/Tiff.cs +++ f-spot-0.1.1/src/Tiff.cs @@ -1112,7 +1112,11 @@ { try { using (System.IO.Stream input = System.IO.File.OpenRead (path)) { - this.Header = new Header (input); + try { + this.Header = new Header (input); + } catch (System.Exception e) { + throw new System.Exception (this.Path, e); + } } ImageDirectory directory = Header.Directory;