Skip to content

Commit

Permalink
Merge pull request #62 from szTheory/hotfix/windows-utf8-filename-bug…
Browse files Browse the repository at this point in the history
…-take2

Windows UTF-8 filename bug - Second attempt
  • Loading branch information
szTheory committed Jul 10, 2020
2 parents a9cd8fb + b28f57e commit 44b241f
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions src/renderer/add_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function cleanExifData(exifHash: any): any {
}

// The heart of the app, removing exif data from the image.
// This uses the Perl binary "exiftool" from .resources with it.
// This uses the Perl binary "exiftool" the app's `.resources` dir
//
// Opening and Closing
//
Expand Down Expand Up @@ -135,7 +135,9 @@ async function removeExif({
.open()
// .then((pid) => console.log('Started exiftool process %s', pid))
.then(() => {
return ep.writeMetadata(filePath, { all: "" }, ["overwrite_original"]);
const args = ["charset filename=UTF8", "overwrite_original"];

return ep.writeMetadata(filePath, { all: "" }, args);
})
.catch(console.error);

Expand All @@ -155,26 +157,21 @@ async function getExif({
.open()
// .then((pid) => console.log('Started exiftool process %s', pid))
.then(() => {
return exiftoolProcess
.readMetadata(filePath, [
"-File:all",
"-ExifToolVersion",
"-x FileSize",
"-x SourceFile"
])
.then(
exifData => {
if (exifData.data === null) {
return {};
}

const hash = exifData.data[0];
return cleanExifData(hash);
},
err => {
console.error(err);
const args = ["charset filename=UTF8", "-File:all", "-ExifToolVersion"];

return exiftoolProcess.readMetadata(filePath, args).then(
exifData => {
if (exifData.data === null) {
return {};
}
);

const hash = exifData.data[0];
return cleanExifData(hash);
},
err => {
console.error(err);
}
);
})
.catch(console.error);

Expand Down

0 comments on commit 44b241f

Please sign in to comment.