fix(windows): resolve some encoding problem with search daemon process

This commit is contained in:
Alexey Kasyanchuk 2018-02-07 00:03:39 +03:00
parent 54d521c95a
commit 7b4f37081f
2 changed files with 6 additions and 1 deletions

View File

@ -75,6 +75,7 @@
"debug": "^3.1.0", "debug": "^3.1.0",
"diskusage": "^0.2.4", "diskusage": "^0.2.4",
"fs-jetpack": "^1.2.0", "fs-jetpack": "^1.2.0",
"iconv-lite": "^0.4.19",
"ipaddr.js": "^1.5.4", "ipaddr.js": "^1.5.4",
"material-ui": "^0.20.0", "material-ui": "^0.20.0",
"moment": "^2.20.1", "moment": "^2.20.1",

View File

@ -19,6 +19,7 @@ import env from "env";
const { spawn, exec } = require('child_process') const { spawn, exec } = require('child_process')
const fs = require('fs') const fs = require('fs')
const iconv = require('iconv-lite');
const setApplicationMenu = () => { const setApplicationMenu = () => {
const menus = [editMenuTemplate, settingsMenuTemplate, aboutMenuTemplate]; const menus = [editMenuTemplate, settingsMenuTemplate, aboutMenuTemplate];
@ -93,7 +94,7 @@ const getSphinxPath = () => {
} }
const writeSphinxConfig = (path, dbPath) => { const writeSphinxConfig = (path, dbPath) => {
const config = ` let config = `
index torrents index torrents
{ {
type = rt type = rt
@ -182,6 +183,9 @@ const writeSphinxConfig = (path, dbPath) => {
fs.mkdirSync(`${dbPath}/database`); fs.mkdirSync(`${dbPath}/database`);
} }
if(/^win/.test(process.platform))
config = iconv.encode(config, 'win1251')
fs.writeFileSync(`${path}/sphinx.conf`, config) fs.writeFileSync(`${path}/sphinx.conf`, config)
console.log(`writed sphinx config to ${path}`) console.log(`writed sphinx config to ${path}`)
console.log('db path:', dbPath) console.log('db path:', dbPath)