gpt4 book ai didi

javascript - 仅当从 Node 运行时,Rsync 才会失败,退出代码为 23

转载 作者:太空宇宙 更新时间:2023-11-04 02:37:53 26 4
gpt4 key购买 nike

我正在使用rsync module使用 Node v0.10.22。从 Node 运行时,Rsync 退出并显示代码 23(由于错误导致部分传输),但从与崩溃的 Node 进程相同的 shell 运行时会成功。

这是我正在使用的代码:

var r = new Rsync()
.flags('a')
.include('*.png')
.exclude('*')
.source(path.join('source/*'))
.destination('target')
.execute(function (err, code, cmd) {
if (err && code === 23) {
console.log('Exited with 23');
console.log(cmd);
}
});

记录的cmd如下:

rsync -a --include="*.png" --exclude="*" source/* target

当我在 Node 在同一个 shell 中崩溃后执行该命令时,该命令返回 0 (没有错误,它有效)。

我查看了 rsync.js 它生成命令的位置:

// Execute the command as a child process
var cmdProc = spawn(this.executable(), this.args(), { stdio: 'pipe' });

this.executable() 返回'rsync'this.args() 返回 ['-a', '--include="*.png"', '--exclude="*", 'source/*', 'target/']

这是怎么回事?为什么从 Node 运行时得到的退出代码与在运行 Node 的同一 shell 中运行不同?

编辑:我将每个目录的权限设置为777,但仍然收到相同的错误。

最佳答案

源代码中的 glob 未展开,因此 rsync 尝试在 source 目录中查找名为 * 的文件。将源更改为 source/

关于javascript - 仅当从 Node 运行时,Rsync 才会失败,退出代码为 23,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20411838/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com