fix: BUG
This commit is contained in:
parent
7c117d0440
commit
0c65c8f0d4
@ -70,6 +70,7 @@ export class TdtmapController {
|
||||
// minio 中存在,从 minio 取出
|
||||
const dbItem:Buffer = await this.tdtmapService.getTileFromLocal(tileFormattedName) // 从 minio 取出来
|
||||
cacheMap.set(tileFormattedName, dbItem)
|
||||
Buffer.from(dbItem as any, 'utf-8')
|
||||
return new StreamableFile(dbItem);
|
||||
} else {
|
||||
// 如果本地数据库都不存在
|
||||
@ -85,7 +86,6 @@ export class TdtmapController {
|
||||
cacheMap.set(tileFormattedName, res.data)
|
||||
const saveSuccess = await this.tdtmapService.setTileToLocal(tileFormattedName, res.data);
|
||||
if (saveSuccess) bloomFilter.add(tileFormattedName);
|
||||
|
||||
Buffer.from(res.data, 'utf-8')
|
||||
return new StreamableFile(res.data); // 请求成功
|
||||
} else {
|
||||
|
@ -30,10 +30,12 @@ export class TdtmapService {
|
||||
async getTileFromLocal(tile_name:string):Promise<Buffer> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const stream = await this.minioClient.getObject("nestfiles", tile_name)
|
||||
let res:any = null
|
||||
stream.on("data", (data) => { res = data })
|
||||
const res:any[] = []
|
||||
stream.on("data", (data:Buffer) => {
|
||||
if (Buffer.isBuffer(data)) res.push(data)
|
||||
})
|
||||
stream.on("end", () => {
|
||||
if (res) resolve(res)
|
||||
if (res.length > 0) resolve(Buffer.concat(res))
|
||||
else reject()
|
||||
})
|
||||
stream.on("error", () => { reject() })
|
||||
|
Loading…
Reference in New Issue
Block a user