Skip to content

Commit b28f57e

Browse files
committed
Fix Windows UTF-8 filename bug (tested)
1 parent 3553160 commit b28f57e

File tree

3 files changed

+17
-79
lines changed

3 files changed

+17
-79
lines changed

src/common/args_file.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/common/temp_file.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/renderer/add_files.ts

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
} from "./table";
66
import exiftool, { ExiftoolProcess } from "node-exiftool";
77
import { exiftoolBinPath } from "../common/binaries";
8-
import { withArgsTempFile } from "../common/args_file";
98

109
export async function addFiles({ filePaths }: { filePaths: string[] }) {
1110
for (const filePath of filePaths) {
@@ -136,13 +135,9 @@ async function removeExif({
136135
.open()
137136
// .then((pid) => console.log('Started exiftool process %s', pid))
138137
.then(() => {
139-
const args = ["-charset filename=UTF8", "overwrite_original"];
138+
const args = ["charset filename=UTF8", "overwrite_original"];
140139

141-
return withArgsTempFile(args, argsTempFilePath => {
142-
return ep.writeMetadata(filePath, { all: "" }, [
143-
`-@ ${argsTempFilePath}`
144-
]);
145-
});
140+
return ep.writeMetadata(filePath, { all: "" }, args);
146141
})
147142
.catch(console.error);
148143

@@ -162,31 +157,21 @@ async function getExif({
162157
.open()
163158
// .then((pid) => console.log('Started exiftool process %s', pid))
164159
.then(() => {
165-
const args = [
166-
"-charset filename=UTF8",
167-
"-File:all",
168-
"-ExifToolVersion",
169-
"-x FileSize",
170-
"-x SourceFile"
171-
];
172-
173-
return withArgsTempFile(args, argsTempFilePath => {
174-
return exiftoolProcess
175-
.readMetadata(filePath, [`-@ ${argsTempFilePath}`])
176-
.then(
177-
exifData => {
178-
if (exifData.data === null) {
179-
return {};
180-
}
181-
182-
const hash = exifData.data[0];
183-
return cleanExifData(hash);
184-
},
185-
err => {
186-
console.error(err);
187-
}
188-
);
189-
});
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 {};
166+
}
167+
168+
const hash = exifData.data[0];
169+
return cleanExifData(hash);
170+
},
171+
err => {
172+
console.error(err);
173+
}
174+
);
190175
})
191176
.catch(console.error);
192177

0 commit comments

Comments
 (0)