Skip to content

Commit

Permalink
fix: Temp files are encoded using default encoding setting (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blashaq authored and JohnstonCode committed Dec 27, 2019
1 parent 5bbd444 commit 6c2748a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/tempFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as path from "path";
import { Uri } from "vscode";
import { exists, mkdir, writeFile } from "./fs";
import * as crypto from "crypto";
import { iconv } from "./vscodeModules";
import { configuration } from "./helpers/configuration";

export const tempdir = path.join(os.tmpdir(), "vscode-svn");

Expand All @@ -19,12 +21,18 @@ export async function createTempSvnRevisionFile(
const hash = crypto.createHash("md5");
const data = hash.update(svnUri.path);
const filePathHash = data.digest("hex");
const encoding = configuration.get<string>("default.encoding");

if (!(await exists(path.join(tempdir, filePathHash)))) {
await mkdir(path.join(tempdir, filePathHash));
}

const fpath = path.join(tempdir, filePathHash, fname);
await writeFile(fpath, payload);
if (encoding) {
const encodedPayload = iconv.encode(payload, encoding);
await writeFile(fpath, encodedPayload);
} else {
await writeFile(fpath, payload);
}
return Uri.file(fpath);
}

0 comments on commit 6c2748a

Please sign in to comment.