chore(fs/createOutputStream): remove deprecated method
Deprecated since 407586e2d
This commit is contained in:
parent
493d861de3
commit
6432a44860
@ -50,7 +50,6 @@
|
|||||||
"@babel/plugin-proposal-decorators": "^7.1.6",
|
"@babel/plugin-proposal-decorators": "^7.1.6",
|
||||||
"@babel/plugin-proposal-function-bind": "^7.0.0",
|
"@babel/plugin-proposal-function-bind": "^7.0.0",
|
||||||
"@babel/preset-env": "^7.8.0",
|
"@babel/preset-env": "^7.8.0",
|
||||||
"async-iterator-to-stream": "^1.1.0",
|
|
||||||
"babel-plugin-lodash": "^3.3.2",
|
"babel-plugin-lodash": "^3.3.2",
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
|
@ -111,41 +111,6 @@ export default class RemoteHandlerAbstract {
|
|||||||
await this.__closeFile(fd)
|
await this.__closeFile(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove method
|
|
||||||
async createOutputStream(file, { checksum = false, dirMode, ...options } = {}) {
|
|
||||||
if (typeof file === 'string') {
|
|
||||||
file = normalizePath(file)
|
|
||||||
}
|
|
||||||
const path = typeof file === 'string' ? file : file.path
|
|
||||||
const streamP = timeout.call(
|
|
||||||
this._createOutputStream(file, {
|
|
||||||
dirMode,
|
|
||||||
flags: 'wx',
|
|
||||||
...options,
|
|
||||||
}),
|
|
||||||
this._timeout
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!checksum) {
|
|
||||||
return streamP
|
|
||||||
}
|
|
||||||
|
|
||||||
const checksumStream = createChecksumStream()
|
|
||||||
const forwardError = error => {
|
|
||||||
checksumStream.emit('error', error)
|
|
||||||
}
|
|
||||||
|
|
||||||
const stream = await streamP
|
|
||||||
stream.on('error', forwardError)
|
|
||||||
checksumStream.pipe(stream)
|
|
||||||
|
|
||||||
checksumStream.checksumWritten = checksumStream.checksum
|
|
||||||
.then(value => this._outputFile(checksumFile(path), value, { flags: 'wx' }))
|
|
||||||
.catch(forwardError)
|
|
||||||
|
|
||||||
return checksumStream
|
|
||||||
}
|
|
||||||
|
|
||||||
createReadStream(file, { checksum = false, ignoreMissingChecksum = false, ...options } = {}) {
|
createReadStream(file, { checksum = false, ignoreMissingChecksum = false, ...options } = {}) {
|
||||||
if (typeof file === 'string') {
|
if (typeof file === 'string') {
|
||||||
file = normalizePath(file)
|
file = normalizePath(file)
|
||||||
@ -510,9 +475,13 @@ export default class RemoteHandlerAbstract {
|
|||||||
|
|
||||||
async _outputStream(path, input, { dirMode, validator }) {
|
async _outputStream(path, input, { dirMode, validator }) {
|
||||||
const tmpPath = `${dirname(path)}/.${basename(path)}`
|
const tmpPath = `${dirname(path)}/.${basename(path)}`
|
||||||
const output = await this.createOutputStream(tmpPath, {
|
const output = await timeout.call(
|
||||||
dirMode,
|
this._createOutputStream(tmpPath, {
|
||||||
})
|
dirMode,
|
||||||
|
flags: 'wx',
|
||||||
|
}),
|
||||||
|
this._timeout
|
||||||
|
)
|
||||||
try {
|
try {
|
||||||
await fromCallback(pipeline, input, output)
|
await fromCallback(pipeline, input, output)
|
||||||
if (validator !== undefined) {
|
if (validator !== undefined) {
|
||||||
|
@ -30,18 +30,6 @@ describe('closeFile()', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('createOutputStream()', () => {
|
|
||||||
it(`throws in case of timeout`, async () => {
|
|
||||||
const testHandler = new TestHandler({
|
|
||||||
createOutputStream: () => new Promise(() => {}),
|
|
||||||
})
|
|
||||||
|
|
||||||
const promise = testHandler.createOutputStream('File')
|
|
||||||
jest.advanceTimersByTime(TIMEOUT)
|
|
||||||
await expect(promise).rejects.toThrowError(TimeoutError)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('getInfo()', () => {
|
describe('getInfo()', () => {
|
||||||
it('throws in case of timeout', async () => {
|
it('throws in case of timeout', async () => {
|
||||||
const testHandler = new TestHandler({
|
const testHandler = new TestHandler({
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
/* eslint-env jest */
|
/* eslint-env jest */
|
||||||
|
|
||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
import asyncIteratorToStream from 'async-iterator-to-stream'
|
|
||||||
import { forOwn, random } from 'lodash'
|
import { forOwn, random } from 'lodash'
|
||||||
import { fromCallback } from 'promise-toolbox'
|
|
||||||
import { pipeline } from 'readable-stream'
|
|
||||||
import { tmpdir } from 'os'
|
import { tmpdir } from 'os'
|
||||||
|
|
||||||
import { getHandler } from '.'
|
import { getHandler } from '.'
|
||||||
@ -27,9 +24,6 @@ const unsecureRandomBytes = n => {
|
|||||||
|
|
||||||
const TEST_DATA_LEN = 1024
|
const TEST_DATA_LEN = 1024
|
||||||
const TEST_DATA = unsecureRandomBytes(TEST_DATA_LEN)
|
const TEST_DATA = unsecureRandomBytes(TEST_DATA_LEN)
|
||||||
const createTestDataStream = asyncIteratorToStream(function* () {
|
|
||||||
yield TEST_DATA
|
|
||||||
})
|
|
||||||
|
|
||||||
const rejectionOf = p =>
|
const rejectionOf = p =>
|
||||||
p.then(
|
p.then(
|
||||||
@ -82,14 +76,6 @@ handlers.forEach(url => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#createOutputStream()', () => {
|
|
||||||
it('creates parent dir if missing', async () => {
|
|
||||||
const stream = await handler.createOutputStream('dir/file')
|
|
||||||
await fromCallback(pipeline, createTestDataStream(), stream)
|
|
||||||
await expect(await handler.readFile('dir/file')).toEqual(TEST_DATA)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('#getInfo()', () => {
|
describe('#getInfo()', () => {
|
||||||
let info
|
let info
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<!--packages-start-->
|
<!--packages-start-->
|
||||||
|
|
||||||
- @vates/async-each major
|
- @vates/async-each major
|
||||||
|
- @xen-orchestra/fs major
|
||||||
- @xen-orchestra/xapi patch
|
- @xen-orchestra/xapi patch
|
||||||
- xo-cli patch
|
- xo-cli patch
|
||||||
- xo-server minor
|
- xo-server minor
|
||||||
|
Loading…
Reference in New Issue
Block a user