Skip to content

Commit

Permalink
Fix Windows UTF-8 filename bug (tested)
Browse files Browse the repository at this point in the history
  • Loading branch information
szTheory committed Jul 10, 2020
1 parent 3553160 commit b28f57e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 79 deletions.
14 changes: 0 additions & 14 deletions src/common/args_file.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/common/temp_file.ts

This file was deleted.

49 changes: 17 additions & 32 deletions src/renderer/add_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from "./table";
import exiftool, { ExiftoolProcess } from "node-exiftool";
import { exiftoolBinPath } from "../common/binaries";
import { withArgsTempFile } from "../common/args_file";

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

return withArgsTempFile(args, argsTempFilePath => {
return ep.writeMetadata(filePath, { all: "" }, [
`-@ ${argsTempFilePath}`
]);
});
return ep.writeMetadata(filePath, { all: "" }, args);
})
.catch(console.error);

Expand All @@ -162,31 +157,21 @@ async function getExif({
.open()
// .then((pid) => console.log('Started exiftool process %s', pid))
.then(() => {
const args = [
"-charset filename=UTF8",
"-File:all",
"-ExifToolVersion",
"-x FileSize",
"-x SourceFile"
];

return withArgsTempFile(args, argsTempFilePath => {
return exiftoolProcess
.readMetadata(filePath, [`-@ ${argsTempFilePath}`])
.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 b28f57e

Please sign in to comment.