Skip to content

Commit 44b241f

Browse files
authored
Merge pull request #62 from szTheory/hotfix/windows-utf8-filename-bug-take2
Windows UTF-8 filename bug - Second attempt
2 parents a9cd8fb + b28f57e commit 44b241f

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/renderer/add_files.ts

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function cleanExifData(exifHash: any): any {
107107
}
108108

109109
// The heart of the app, removing exif data from the image.
110-
// This uses the Perl binary "exiftool" from .resources with it.
110+
// This uses the Perl binary "exiftool" the app's `.resources` dir
111111
//
112112
// Opening and Closing
113113
//
@@ -135,7 +135,9 @@ async function removeExif({
135135
.open()
136136
// .then((pid) => console.log('Started exiftool process %s', pid))
137137
.then(() => {
138-
return ep.writeMetadata(filePath, { all: "" }, ["overwrite_original"]);
138+
const args = ["charset filename=UTF8", "overwrite_original"];
139+
140+
return ep.writeMetadata(filePath, { all: "" }, args);
139141
})
140142
.catch(console.error);
141143

@@ -155,26 +157,21 @@ async function getExif({
155157
.open()
156158
// .then((pid) => console.log('Started exiftool process %s', pid))
157159
.then(() => {
158-
return exiftoolProcess
159-
.readMetadata(filePath, [
160-
"-File:all",
161-
"-ExifToolVersion",
162-
"-x FileSize",
163-
"-x SourceFile"
164-
])
165-
.then(
166-
exifData => {
167-
if (exifData.data === null) {
168-
return {};
169-
}
170-
171-
const hash = exifData.data[0];
172-
return cleanExifData(hash);
173-
},
174-
err => {
175-
console.error(err);
160+
const args = ["charset filename=UTF8", "-File:all", "-ExifToolVersion"];
161+
162+
return exiftoolProcess.readMetadata(filePath, args).then(
163+
exifData => {
164+
if (exifData.data === null) {
165+
return {};
176166
}
177-
);
167+
168+
const hash = exifData.data[0];
169+
return cleanExifData(hash);
170+
},
171+
err => {
172+
console.error(err);
173+
}
174+
);
178175
})
179176
.catch(console.error);
180177

0 commit comments

Comments
 (0)