+ boost::filesystem::path asset = _picture_asset->file().get();
+
+ /* If there is an existing asset, break any hard links to it as we are about to change its contents
+ (if only by changing the IDs); see #1126.
+ */
+
+ if (boost::filesystem::exists(asset) && boost::filesystem::hard_link_count(asset) > 1) {
+ boost::filesystem::copy_file (asset, asset.string() + ".tmp");
+ boost::filesystem::remove (asset);
+ boost::filesystem::rename (asset.string() + ".tmp", asset);
+ }
+
+ /* Try to open the existing asset */
+ FILE* asset_file = fopen_boost (asset, "rb");