diff --git a/CHANGELOG.md b/CHANGELOG.md index f7243f783..cd2fb6fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- [SIL.Windows.Forms.ClearShare] Fixed Metadata.LoadProperties to catch the ArgumentOutOfRangeException thrown by TagLib.File.Create when unknown data is found in the IPTC profile segment. The rest of the metadata (Exif / XMP) is likely to be okay, but won't be available until TagLib is fixed to allow this. Not having the metadata available shouldn't prevent using the image. Note that clients can now read the exception caught while loading if so desired. - [SIL.Windows.Forms.WritingSystem.WSIdentifiers] Changed ComboBox controls in WSIdentifierView and ScriptRegionVariantView to DropDownList style to prevent accidental editing that shouldn't happen - [SIL.Windows.Forms.ClearShare] Make Metadata.Write (and a few other methods) more robust - [SIL.Core.Desktop] Make FileUtils.ReplaceFileWithUserInteractionIfNeeded robust diff --git a/SIL.Windows.Forms/ClearShare/Metadata.cs b/SIL.Windows.Forms/ClearShare/Metadata.cs index 4e31ab61b..25361c16f 100644 --- a/SIL.Windows.Forms/ClearShare/Metadata.cs +++ b/SIL.Windows.Forms/ClearShare/Metadata.cs @@ -101,6 +101,8 @@ public bool IsOutOfMemoryPlausible(OutOfMemoryException ex) return false; } + public Exception ExceptionCaughtWhileLoading; + /// /// NB: this is used in 2 places; one is loading from the image we are linked to, the other from a sample image we are copying metadata from /// @@ -110,16 +112,18 @@ private static void LoadProperties(string path, Metadata destinationMetadata) { try { + destinationMetadata.ExceptionCaughtWhileLoading = null; destinationMetadata._originalTaglibMetadata = RetryUtility.Retry(() => TagLib.File.Create(path) as TagLib.Image.File, memo:$"LoadProperties({path})"); } - catch (TagLib.UnsupportedFormatException) + catch (TagLib.UnsupportedFormatException ex) { // TagLib throws this exception when the file doesn't have any metadata, sigh. // So since I don't see a way to differentiate between that case and the case // where something really is wrong, we're just gonna have to swallow this, // even in DEBUG mode, because else a lot of simple image tests fail + destinationMetadata.ExceptionCaughtWhileLoading = ex; return; } catch (NotImplementedException ex) @@ -130,6 +134,18 @@ private static void LoadProperties(string path, Metadata destinationMetadata) // problem, but have other limitations. // See https://issues.bloomlibrary.org/youtrack/issue/BL-8706 for a user complaint. System.Diagnostics.Debug.WriteLine($"TagLib exception: {ex}"); + destinationMetadata.ExceptionCaughtWhileLoading = ex; + return; + } + catch (ArgumentOutOfRangeException ex) + { + // TagLib can throw this if it can't read some part of the metadata. This + // prevents us from even looking at images that have such metadata, which + // seems unreasonable. (TagLib doesn't fully understand IPTC profiles, for + // example, which can lead to this exception.) + // See https://issues.bloomlibrary.org/youtrack/issue/BL-11933 for a user complaint. + System.Diagnostics.Debug.WriteLine($"TagLib exception: {ex}"); + destinationMetadata.ExceptionCaughtWhileLoading = ex; return; } LoadProperties(destinationMetadata._originalTaglibMetadata.ImageTag, destinationMetadata);