mirror of
https://github.com/cupcakearmy/morphus.git
synced 2024-12-22 08:06:30 +00:00
fix bug on local
This commit is contained in:
parent
432d9dd140
commit
6f3f9dd9d9
@ -1,6 +1,7 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { join, resolve } from 'path'
|
import { join, resolve } from 'path'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
|
import { App } from '..'
|
||||||
|
|
||||||
import { Storage } from './'
|
import { Storage } from './'
|
||||||
|
|
||||||
@ -37,8 +38,9 @@ export class Local implements Storage {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
readStream(path: string): Promise<NodeJS.ReadableStream> {
|
async readStream(path: string): Promise<NodeJS.ReadableStream> {
|
||||||
const file = join(this.root, path)
|
const file = join(this.root, path)
|
||||||
|
if (!(await this.exists(path))) throw new Error(`File not found: ${path}`)
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const stream = fs.createReadStream(file)
|
const stream = fs.createReadStream(file)
|
||||||
stream.on('error', reject)
|
stream.on('error', reject)
|
||||||
|
Loading…
Reference in New Issue
Block a user