Skip to content

Commit

Permalink
destroy httpRequest after used (#2503)
Browse files Browse the repository at this point in the history
Co-authored-by: xieqin <[email protected]>
Co-authored-by: kevingpqi123 <[email protected]>
  • Loading branch information
3 people authored Sep 29, 2024
1 parent 464ac8d commit 8aab41f
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit 8aab41f

Please sign in to comment.