From 91c99d1b4bdae60afa9e0c4c451b40c7e5b5886d Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Wed, 7 Feb 2018 00:03:39 +0300 Subject: [PATCH] fix(windows): resolve some encoding problem with search daemon process --- package.json | 1 + src/background/background.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6a134903..f79ad285 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "debug": "^3.1.0", "diskusage": "^0.2.4", "fs-jetpack": "^1.2.0", + "iconv-lite": "^0.4.19", "ipaddr.js": "^1.5.4", "material-ui": "^0.20.0", "moment": "^2.20.1", diff --git a/src/background/background.js b/src/background/background.js index 43643c63..ea2edf34 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -19,6 +19,7 @@ import env from "env"; const { spawn, exec } = require('child_process') const fs = require('fs') +const iconv = require('iconv-lite'); const setApplicationMenu = () => { const menus = [editMenuTemplate, settingsMenuTemplate, aboutMenuTemplate]; @@ -93,7 +94,7 @@ const getSphinxPath = () => { } const writeSphinxConfig = (path, dbPath) => { - const config = ` + let config = ` index torrents { type = rt @@ -182,6 +183,9 @@ const writeSphinxConfig = (path, dbPath) => { fs.mkdirSync(`${dbPath}/database`); } + if(/^win/.test(process.platform)) + config = iconv.encode(config, 'win1251') + fs.writeFileSync(`${path}/sphinx.conf`, config) console.log(`writed sphinx config to ${path}`) console.log('db path:', dbPath)