Project

General

Profile

Bug #836

writeMetadata() destroys resource fork on MacOS X for big files (>1MB)

Added by Volker Grabsch over 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Category:
basicio
Target version:
Start date:
03 Aug 2012
Due date:
% Done:

100%

Estimated time:

Description

Under MacOS X, if an image has a file size greater than 1MB, writeMetadata() destroys the image's resource fork.

This leads to all types of strange effects. One example, from a typical designer workflow: You save a file in Photoshop as EPS, and tell the MacOS X Finder to open that specific file with Photoshop rather than Illustator. You don't set this globally, as you only want Photoshop to (re-)open those EPS files originally created by Photoshop, and all other EPS files with a vector graphics tool such as Illustrator. If you then adjust the metadata using the Exiv2 library, the file no longer opens automatically with Photoshop, but with the standard vector tool. This happens because the information that you want to open that specific file with Photoshop was stored in the resource fork which has been destroyed by Exiv2.

Since files which are at most 1MB are written "in place", those don't suffer from the problem. However, a file greater than 1MB is written to a temp file (that has no resource fork), which is then moved (renamed) over the old file. That's why the resource fork is lost here.

This issue is partly connected with bug #812 (see also http://dev.exiv2.org/boards/3/topics/1103), where the "tempfile+move" mechanism destroyed hard links. However, although the solution of #812 would also be applicable here, I don't think it is a good idea to use the "in place" mechanism for all files under MacOS X. That would lead to huge memory consumption when writing metadata to big image files.

Instead, the temporary file mechanism of BasicIo::temporary() should be improved to copy the original file's extended attributes (which contain the resource fork, among others) into the newly created temporary file.


Related issues

Related to Exiv2 - Bug #910: Bug #836 possibly reintroduced: writeMetadata() destroys resource fork on MacOS X for big files (>1MB)Assigned25 Jul 2013

Actions

Associated revisions

Revision 2794 (diff)
Added by Volker Grabsch over 9 years ago

#836: Add test case (currently failing on MacOS X)

Revision 2795 (diff)
Added by Volker Grabsch over 9 years ago

#836: Improve test case

Revision 2796 (diff)
Added by Volker Grabsch over 9 years ago

#836: Copy over xattr (extended attributes, such as resource forks) when creating temporary files

History

#1

Updated by Volker Grabsch over 9 years ago

This idea could be generalized further to preserve not just the extended attributes of MacOS X, but also of Linux, FreeBSD and others. However, preserving the MacOS X extended attributes is currently the most pressing need. So I opened that as a separate feature request: #837.

#2

Updated by Volker Grabsch over 9 years ago

  • Status changed from New to Assigned
  • Assignee set to Volker Grabsch
  • % Done changed from 0 to 20
#3

Updated by Volker Grabsch over 9 years ago

  • Status changed from Assigned to Feedback
  • Assignee changed from Volker Grabsch to Andreas Huggel
  • % Done changed from 20 to 100

I just fixed this issue and added a test case for it.

This mechanism could have been added to FileIo::temporary() as well as FileIo::transfer(). I decided to add it to FileIo::temporary().

@Andreas: Please check if my solution makes sense to you.

#4

Updated by Robin Mills over 8 years ago

  • Status changed from Feedback to Closed

Fixed in 0.4.

Also available in: Atom PDF