fix(fs/smb#create{Read,Write}Stream): works with opened files (#3785)

This commit is contained in:
Julien Fontanet 2018-12-12 15:38:54 +01:00 committed by GitHub
parent 1f497aa4df
commit 995e6664f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,17 +63,23 @@ export default class SmbHandler extends RemoteHandlerAbstract {
}
_createReadStream(file, options) {
// FIXME ensure that options are properly handled by @marsaud/smb2
return this._client
.createReadStream(this._getFilePath(file), options)
.catch(normalizeError)
if (typeof file === 'string') {
file = this._getFilePath(file)
} else {
options = { autoClose: false, ...options, fd: file.fd }
file = ''
}
return this._client.createReadStream(file, options).catch(normalizeError)
}
_createWriteStream(file, options) {
// FIXME ensure that options are properly handled by @marsaud/smb2
return this._client
.createWriteStream(this._getFilePath(file), options)
.catch(normalizeError)
if (typeof file === 'string') {
file = this._getFilePath(file)
} else {
options = { autoClose: false, ...options, fd: file.fd }
file = ''
}
return this._client.createWriteStream(file, options).catch(normalizeError)
}
_forget() {