adbkit
adbkit copied to clipboard
Is there any direct way to pull a directory from device like the command 'adb pull dir' ?
As the subject, I'd like to look for an easier and better-performing way to pull all the files in a directory. Now I used readdir and pull in adbkit:
client.listDevices()
.then(function(devices) {
return Promise.map(devices, function(device) {
return client.readdir(device.id, dir)
.then(function(files) {
files.forEach(function(file) {
if (file.isFile()) {
client.pull(device.id, path.join(dir, file.name))
.then(function(transfer) {
return new Promise(function(resolve, reject) {
var fn = path.join(localDir, file.name)
transfer.on('progress', function(stats) {
console.log('[%s] Pulled %d bytes so far',
device.id,
stats.bytesTransferred)
})
transfer.on('end', function() {
console.log('[%s] Pull file %s complete', device.id, fn)
resolve(device.id)
})
transfer.on('error', reject)
transfer.pipe(fs.createWriteStream(fn))
})
})
}
})
})
})
})
Try rewriting it with with a single syncService() per device. It might not be able to do transfers in parallel (I don’t remember), but I don’t think that will be much of an issue. Try it out.