*handleBuffer should return a promise to operate in order
This commit is contained in:
parent
eb65cc6b10
commit
d79086ad00
|
@ -282,7 +282,7 @@ export default class IpfsProvider extends BaseProvider {
|
||||||
|
|
||||||
const handleBuffer = () => {
|
const handleBuffer = () => {
|
||||||
if (buffer.length) {
|
if (buffer.length) {
|
||||||
filterPromise.then(() => {
|
return filterPromise.then(() => {
|
||||||
streamPromise = streamPromise.then(() => {
|
streamPromise = streamPromise.then(() => {
|
||||||
let mode = contentModes[contentType as string];
|
let mode = contentModes[contentType as string];
|
||||||
buffer = buffer.map((item: Uint8Array | ArrayBuffer) => {
|
buffer = buffer.map((item: Uint8Array | ArrayBuffer) => {
|
||||||
|
@ -307,14 +307,19 @@ export default class IpfsProvider extends BaseProvider {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
if (cachedPage) {
|
if (cachedPage) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
cachedPage.data.arrayBuffer().then((data: ArrayBuffer) => {
|
cachedPage.data.arrayBuffer().then((data: ArrayBuffer) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
receiveUpdate(new Uint8Array(data))?.then(() => {
|
receiveUpdate(new Uint8Array(data))
|
||||||
handleBuffer();
|
?.then(() => {
|
||||||
filterPromise.then(() => filter.close());
|
return handleBuffer();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return filterPromise.then(() => filter.close());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -324,8 +329,8 @@ export default class IpfsProvider extends BaseProvider {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
fetchMethod?.(hash, urlPath, receiveUpdate)
|
fetchMethod?.(hash, urlPath, receiveUpdate)
|
||||||
.then(() => streamPromise)
|
.then(() => streamPromise)
|
||||||
|
.then(() => handleBuffer())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
handleBuffer();
|
|
||||||
filterPromise.then(() => streamPromise).then(() => filter.close());
|
filterPromise.then(() => streamPromise).then(() => filter.close());
|
||||||
resp = resp as StatFileResponse;
|
resp = resp as StatFileResponse;
|
||||||
if (resp.size <= MAX_CACHE_SIZE) {
|
if (resp.size <= MAX_CACHE_SIZE) {
|
||||||
|
|
Reference in New Issue