Skip to content

Commit

Permalink
Own execa (#191)
Browse files Browse the repository at this point in the history
* move menu

* fixing

* 花了快3年,突然就搞定了encoding  可能是因为我最近用炒股软件,需要关闭unicode选项吧

* Update FileChangeToolbar.js

* own_execa

* run sql in sequence

* 老早以前做的,忘记加readme

* Update README.md
  • Loading branch information
hjyssg authored Sep 27, 2021
1 parent e291056 commit 4fcfad7
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 25 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ docker run -d -p hostport:3000 -v comicpath:/data liwufan/shigureader

[热心人总结的](https://github.com/hjyssg/ShiguReader/issues/90)

##### 和everything一起使用

这样就可以电脑全局搜索了
![screenshot-07](screenshot/07.png)

##### 和tamper monkey一起使用

Expand Down
7 changes: 6 additions & 1 deletion pkg_build.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
npm run build && pkg src/server/index.js --targets win-x64 --output ShiguReader.exe
安装nasm https://www.nasm.us/

https://github.com/vercel/pkg/issues/419

npm run build && pkg src/server/index.js --targets win-x64 --debug --output ShiguReader.exe


cd ..
Expand All @@ -14,6 +18,7 @@ cp ShiguReader/path-config.ini ShiguReader_Portable
cp ShiguReader/etc-config.ini ShiguReader_Portable
cp ShiguReader/move-path-config.ini ShiguReader_Portable

cp ShiguReader/node_modules/_sqlite3@5.0.0@sqlite3/lib/binding/napi-v3-win32-x64/node_sqlite3.node ShiguReader_Portable

cp ShiguReader/README.md ShiguReader_Portable
cp ShiguReader/README_English.md ShiguReader_Portable
Expand Down
Binary file added screenshot/07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/client/ExplorerPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,15 @@ export default class ExplorerPage extends Component {
files = _.sortBy(files, e => {
return this.getPageNum(e);
});
}else{
const onlyByMTime = this.getMode() === MODE_EXPLORER && !this.isLackInfoMode();
const config = {
fileInfos: this.allfileInfos,
ascend: true,
getBaseName,
onlyByMTime
}
files = sortUtil.sort_file_by_time(files, config);
}

if (!isSortAsc) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/imageMagickHelp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const execa = require('execa');
const execa = require('./own_execa');
const pfs = require('promise-fs');
const _ = require('underscore');
const logger = require("./logger");
Expand Down
16 changes: 14 additions & 2 deletions src/server/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const express = require('express');
const path = require('path');
const execa = require('execa');

const pfs = require('promise-fs');
const dateFormat = require('dateformat');
const _ = require('underscore');
Expand All @@ -11,11 +11,12 @@ const ini = require('ini');

global.requireUtil = () => require("../common/util");


global.requireUserConfig = () => require("../config/user-config");

global.requireConstant = () => require("../common/constant");


const execa = require('./own_execa');
const userConfig = global.requireUserConfig();
const util = global.requireUtil();

Expand Down Expand Up @@ -785,6 +786,17 @@ app.post('/api/getGeneralInfo', async (req, res) => {
});


// // check if login
// router.use((req, res, next) => {
// console.log(req.cookies, req.method, req.url)

// if(req.cookies["login_user_id"] || req.method === "POST"){
// next();
// }else{
// res.redirect("/login")
// }
// })

//---------------------------
const homePagePath = require("./routes/homePagePath");
app.use(homePagePath);
Expand Down
3 changes: 1 addition & 2 deletions src/server/models/historyDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const rootPath = pathUtil.getRootPath();
const history_db_path = path.join(rootPath, userConfig.workspace_name, "history_sql_db");
const sqlite3 = require('sqlite3').verbose();
const sqlDb = new sqlite3.Database(history_db_path);
sqlDb.run("CREATE TABLE IF NOT EXISTS history_table (filePath TEXT NOT NULL, dirPath TEXT, fileName TEXT, time INTEGER)");
sqlDb.run("CREATE INDEX IF NOT EXISTS fileName_index ON history_table (fileName)");
sqlDb.run("CREATE TABLE IF NOT EXISTS history_table (filePath TEXT NOT NULL, dirPath TEXT, fileName TEXT, time INTEGER); CREATE INDEX IF NOT EXISTS fileName_index ON history_table (fileName)");


const _util = require('util');
Expand Down
3 changes: 1 addition & 2 deletions src/server/models/thumbnailDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const rootPath = pathUtil.getRootPath();
let thumbnail_db_path = path.join(rootPath, userConfig.workspace_name, "thumbnail_sql_db");
const sqlite3 = require('sqlite3').verbose();
const sqlDb = new sqlite3.Database(thumbnail_db_path);
sqlDb.run("CREATE TABLE IF NOT EXISTS thumbnail_table (filePath TEXT, thumbnailFileName TEXT);");
sqlDb.run("CREATE INDEX IF NOT EXISTS filePath_index ON thumbnail_table (filePath)");
sqlDb.run("CREATE TABLE IF NOT EXISTS thumbnail_table (filePath TEXT, thumbnailFileName TEXT); CREATE INDEX IF NOT EXISTS filePath_index ON thumbnail_table (filePath)");

const _util = require('util');
sqlDb.allSync = _util.promisify(sqlDb.all).bind(sqlDb);
Expand Down
2 changes: 1 addition & 1 deletion src/server/moveDeleteHelp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const isWindows = require('is-windows');
const execa = require('execa');
const execa = require('./own_execa');

module.exports.move = async function (src, dest) {
const cmdStr = isWindows() ? "move" : "mv";
Expand Down
26 changes: 26 additions & 0 deletions src/server/own_execa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const _execa = require('execa');
const iconv = require('iconv-lite');


async function execa(cmd, option){
if(global._cmd_encoding === 65001){
let { stdout, stderr } = await _execa(cmd, option, { timeout: 60000 });
return { stdout, stderr }
}else{
try{
let { stdout, stderr } = await _execa(cmd, option, { timeout: 60000, encoding: null });
// only support chinese os for now
stdout = iconv.decode(stdout, 'gbk');
stderr = iconv.decode(stderr, 'gbk');
return { stdout, stderr }
}catch (err) {
err.stdout = iconv.decode(err.stdout, 'gbk');
err.stderr = iconv.decode(err.stderr, 'gbk');
throw err;
}

}
}


module.exports = execa;
2 changes: 1 addition & 1 deletion src/server/routes/moveOrDelete.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');
const pfs = require('promise-fs');
const execa = require('execa');
const execa = require('../own_execa');
const userConfig = global.requireUserConfig();
const isWindows = require('is-windows');
const express = require('express');
Expand Down
17 changes: 4 additions & 13 deletions src/server/sevenZipHelp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const execa = require('execa');
const execa = require('./own_execa');
const pfs = require('promise-fs');
const _ = require('underscore');
const isWindows = require('is-windows');
Expand Down Expand Up @@ -118,18 +118,9 @@ module.exports.listZipContentAndUpdateDb = async function (filePath) {
let text;
let _stderr;

//https://superuser.com/questions/1020232/list-zip-files-contents-using-7zip-command-line-with-non-verbose-machine-friend
if(global._cmd_encoding === 65001){
let { stdout, stderr } = await execa(sevenZip, ['l', '-r', '-ba', '-slt', filePath], { timeout: 5000 });
text = stdout;
_stderr = stderr;
}else{
let { stdout, stderr } = await execa(sevenZip, ['l', '-r', '-ba', '-slt', filePath], { timeout: 5000, encoding: null });
// only support chinese os for now
stdout = iconv.decode(stdout, 'gbk');
text = stdout;
_stderr = iconv.decode(stderr, 'gbk');
}
let { stdout, stderr } = await execa(sevenZip, ['l', '-r', '-ba', '-slt', filePath], { timeout: 5000 });
text = stdout;
_stderr = stderr;

if (!text || _stderr || LIST_QUEUE[filePath]) {
return emptyResult;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/deprecated/reduceZipSize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const execa = require('execa');
const execa = require('./own_execa');
const fs = require('fs');
const path = require('path');
const unzip_cache = "unzip_cache";
Expand Down
2 changes: 1 addition & 1 deletion src/tools/thumbnailGenerator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');
const path = require('path');
const util = global.requireUtil();
const execa = require('execa');
const execa = require('../server/own_execa');

async function thumbnailGenerator(thumbnailFolderPath, imgFolder, fileName) {
let outputFilePath = null;
Expand Down

0 comments on commit 4fcfad7

Please sign in to comment.