fix(xo-web): avoid using TextDecoder (#3718)
This is an experimental API and not really necessary here.
This commit is contained in:
parent
2e1ac27cf5
commit
2da576a1f8
@ -83,7 +83,7 @@ const filterDisks = disks => {
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
/* global FileReader, TextDecoder */
|
||||
/* global FileReader */
|
||||
|
||||
async function readFileFragment (file, start = 0, end) {
|
||||
const reader = new FileReader()
|
||||
@ -92,18 +92,21 @@ async function readFileFragment (file, start = 0, end) {
|
||||
}
|
||||
|
||||
function parseTarHeader (header) {
|
||||
const textDecoder = new TextDecoder('ascii')
|
||||
const fileName = textDecoder.decode(header.slice(0, 100)).split('\0')[0]
|
||||
const fileName = Buffer.from(header.slice(0, 100))
|
||||
.toString('ascii')
|
||||
.split('\0')[0]
|
||||
if (fileName.length === 0) {
|
||||
return null
|
||||
}
|
||||
const fileSize = parseInt(textDecoder.decode(header.slice(124, 124 + 11)), 8)
|
||||
const fileSize = parseInt(
|
||||
Buffer.from(header.slice(124, 124 + 11)).toString('ascii'),
|
||||
8
|
||||
)
|
||||
return { fileName, fileSize }
|
||||
}
|
||||
|
||||
async function parseOVF (fileFragment) {
|
||||
const textDecoder = new TextDecoder('utf-8')
|
||||
const xmlString = textDecoder.decode(await readFileFragment(fileFragment))
|
||||
const xmlString = Buffer.from(await readFileFragment(fileFragment)).toString()
|
||||
return new Promise((resolve, reject) =>
|
||||
xml2js.parseString(
|
||||
xmlString,
|
||||
|
Loading…
Reference in New Issue
Block a user