remove broken import

This commit is contained in:
Florent Beauchamp
2024-02-09 16:07:24 +00:00
parent 1e0c411d5f
commit b3e163d090

View File

@@ -13,8 +13,8 @@ const {
} = require('./_constants') } = require('./_constants')
const { fuHeader, checksumStruct } = require('./_structs') const { fuHeader, checksumStruct } = require('./_structs')
const assert = require('node:assert') const assert = require('node:assert')
const { NBD_DEFAULT_BLOCK_SIZE } = require('@vates/nbd-client/constants.mjs')
const NBD_DEFAULT_BLOCK_SIZE = 64 * 1024
const MAX_DURATION_BETWEEN_PROGRESS_EMIT = 5e3 const MAX_DURATION_BETWEEN_PROGRESS_EMIT = 5e3
const MIN_TRESHOLD_PERCENT_BETWEEN_PROGRESS_EMIT = 1 const MIN_TRESHOLD_PERCENT_BETWEEN_PROGRESS_EMIT = 1
@@ -35,25 +35,23 @@ exports.createNbdRawStream = function createRawStream(nbdClient) {
return stream return stream
} }
function batContainsBlock(bat, blockId) { function batContainsBlock(bat, blockId) {
const entry = bat.readUInt32BE(blockId * 4) const entry = bat.readUInt32BE(blockId * 4)
if (entry !== BLOCK_UNUSED) { if (entry !== BLOCK_UNUSED) {
return [{ blockId, size: DEFAULT_BLOCK_SIZE }] return [{ blockId, size: DEFAULT_BLOCK_SIZE }]
} }
} }
// one 2MB VHD block is in 32 blocks of 64KB // one 2MB VHD block is in 32 blocks of 64KB
// 32 bits are written in 8 4bytes uint32 // 32 bits are written in 8 4bytes uint32
const EMPTY_NBD_BUFFER = Buffer.alloc(NBD_DEFAULT_BLOCK_SIZE, 0) const EMPTY_NBD_BUFFER = Buffer.alloc(NBD_DEFAULT_BLOCK_SIZE, 0)
function cbtContainsBlock(cbt, blockId) { function cbtContainsBlock(cbt, blockId) {
let subBlocks = [] const subBlocks = []
let hasOne = false let hasOne = false
for (let i = 0; i < 32; i++) { for (let i = 0; i < 32; i++) {
let position = blockId * 32 + i const position = blockId * 32 + i
const bitOffset = position & 7; // in byte const bitOffset = position & 7 // in byte
const byteIndex = position >> 3; // in buffer const byteIndex = position >> 3 // in buffer
const bit = (buffer[byteIndex] >> bitOffset) & 1; const bit = (cbt[byteIndex] >> bitOffset) & 1
if (bit === 1) { if (bit === 1) {
subBlocks.push({ blockId: position, size: NBD_DEFAULT_BLOCK_SIZE }) subBlocks.push({ blockId: position, size: NBD_DEFAULT_BLOCK_SIZE })
hasOne = true hasOne = true