Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroy httpRequest after used #2503

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ohos/libpag/src/main/ets/PAGFile.ets
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
//
/////////////////////////////////////////////////////////////////////////////////////////////////

import { JPAGDiskCache, JPAGFile, JPAGLayer } from 'libpag.so'
import { PAGComposition } from './PAGComposition'
import { JPAGDiskCache, JPAGFile, JPAGLayer } from 'libpag.so';
import { PAGComposition } from './PAGComposition';
import { resourceManager } from '@kit.LocalizationKit';
import { PAGLayer, PAGLayerType } from './PAGLayer';
import { PAGText } from './PAGText';
Expand Down Expand Up @@ -52,7 +52,6 @@ export enum PAGTimeStretchMode {
}

export class PAGFile extends PAGComposition {

constructor(nativeLayer: JPAGLayer) {
super(nativeLayer);
}
Expand Down Expand Up @@ -95,7 +94,7 @@ export class PAGFile extends PAGComposition {
* cache is alive until all PAGFiles are released. Use 'PAGFile.LoadFromBytes()' instead
* if you don't want to load a PAGFile from the internal caches.
*/
static LoadFromPathAsync(filePath: string): Promise<PAGFile | null> {
static LoadFromPathAsync(filePath: string): Promise<PAGFile | null> {
PAGInit.Init();
return new Promise<PAGFile | null>((resolve, reject) => {
if (filePath == null) {
Expand Down Expand Up @@ -126,6 +125,9 @@ export class PAGFile extends PAGComposition {
console.error(`download file failed! filePath: ${filePath}`);
reject(error);
})
.finally(() => {
httpRequest.destroy()
})
}
} else {
let native = JPAGFile.LoadFromPath(filePath);
Expand Down