Closed mattpr closed 10 months ago
Thanks for bringing this issue up!
I think it would be better to rely on exit code from exiftool
For performance reasons, I run exiftool
in "batch" mode, so there's no exit code to check.
The errors (like file not found) are easy to handle, as ExifTool will emit to stderr
--I think it's defensible to throw an error if exiftool renders to stderr.
but if exiftool actually failed (missing binary, input file doesn't exist, etc)...I want to know and parsing error messages from your lib feels like a brittle way to do this.
Totally agreed. So--I could
ExifTool.write
to return a Promise<something>
that indicates the operation was a no-op.I think I prefer 2. It's a breaking change, but I think it's better than what I've got currently.
So: what's something
look like?
{state: "created" | "updated" | "unchanged"}
{noop: boolean}
{created?: number; updated?: number; unchanged?: number}
Option 1. allows for discrimination for creates vs updates, but checking a boolean might be a bit simpler than messing with a string enum.
Option 3 requires consumers to query a bunch of fields, but supports writes to filenames with globs, like:
exiftool -Author= foo*.xmp
1 image files updated
6 image files unchanged
OK, I'm implementing Option 3:
export interface WriteTaskResult {
created: number
updated: number
unchanged: number
warnings?: string[]
}
Hey! Thanks for the fast response and turnaround on a patch. I appreciate it!
Describe the bug
Stripping metadata from PDF files during a "build" process, I'm hitting an error due to a regex mismatch.
The regex (
/1 image files? (?:created|updated)/i
) is looking for1 image files
.However as we are stripping tags that may or may not be there, the output from exiftool may be something like this:
ie the below will result in
exiftool-vendored
blowing up:...the above looks like success to me. exiftool didn't do anything because
some.pdf
did not have an Author tag.Unfortunately this lib just throws an error in these cases. Sure I can catch it and ignore it...but if exiftool actually failed (missing binary, input file doesn't exist, etc)...I want to know and parsing error messages from your lib feels like a brittle way to do this.
I think it would be better to rely on exit code from
exiftool
rather than trying to parse stderr/out and then surface stderr/out when you get a non-zero exit.But the quick fix would be to add
unchanged
to the regex.