最终证明这是一个个性化的错误。
上传本地apk进行安装时,进行到50%之后就报错——导致系统推出。
2020-7-20 15:38:02 INF/storage:temp 17950 [*] Uploaded "67a219fbe4ce8e2ab4c1fc5ce60195d3" to "/home/stf/tempSaveDir/upload_a0cfd8e997b752e14aecb2202cb0c1c4"
2020-7-20 15:38:02 INF/websocket 17944 [*] installMsg manifest undefined
/home/stf/RemoteDeviceNew/node_modules/protobufjs/dist/ProtoBuf.js:2641
throw Error("Illegal value for "+this.toString(true)+" of type "+this.type.name+": "+val+" ("+msg+")");
^
Error: Illegal value for Message.Field .InstallMessage.manifest of type string: undefined (not a string)
at Field.<anonymous> (/home/stf/RemoteDeviceNew/node_modules/protobufjs/dist/ProtoBuf.js:2641:27)
at Field.ProtoBuf.Reflect.FieldPrototype.verifyValue (/home/stf/RemoteDeviceNew/node_modules/protobufjs/dist/ProtoBuf.js:2721:29)
at MessagePrototype.set (/home/stf/RemoteDeviceNew/node_modules/protobufjs/dist/ProtoBuf.js:1799:63)
at new Message (/home/stf/RemoteDeviceNew/node_modules/protobufjs/dist/ProtoBuf.js:1728:42)
at Socket.<anonymous> (/home/stf/RemoteDeviceNew/lib/units/websocket/index.js:830:15)
at emitThree (events.js:136:13)
at Socket.emit (events.js:217:7)
at /home/stf/RemoteDeviceNew/node_modules/socket.io/lib/socket.js:528:12
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
2020-7-20 15:38:02 FTL/cli:local 17862 [*] Child process had an error ExitError: Exit code "1"
at ChildProcess.<anonymous> (/home/stf/RemoteDeviceNew/lib/util/procutil.js:49:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
重新加载为数不多的前端知识,先搜索对应的关键字,在对应的位置增加log信息。
lib/units/websocket/index.js
830行报错,同时提示.InstallMessage.manifest of type string: undefined
。可以推测出没有获取到apk的manifest信息。
// lib/units/websocket/index.js
.on('device.install', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.InstallMessage(
data.href
, data.launch === true
, JSON.stringify(data.manifest)
)
)
])
})
// wire.proto
message InstallMessage {
required string href = 1;
required bool launch = 2;
optional string manifest = 3;
}
拿到原始的apk分析后,是正常的文件,可以正常安装。
前端处理上传文件并进行安装的服务为res/app/components/stf/install/install-service.js
。进度到50%时,实际上已经将文件上传成功了,然后开始进行安装的动作。通过文件后缀来区分apk和ipa的区别(这块是定制的内容)。看起来是像是通过http强求获取manifest文件内容的?这块先忽略。
看本地上传文件的处理lib/units/storage/temp.js
注意到log内容包含Uploaded "67a219fbe4ce8e2ab4c1fc5ce60195d3" to "/home/stf/tempSaveDir/upload_a0cfd8e997b752e14aecb2202cb0c1c4"
似乎文件名做了处理。
跟踪了一下这个temp.js文件的git历史记录,看起来是同步代码时增加了一部分处理文件的操作——
form.on('fileBegin', function(name, file) {
var md5 = crypto.createHash('md5')
file.name = md5.update(file.name).digest('hex')
})
将这段代码删除后,恢复正常。
网友评论