Skip to content

Commit e594d50

Browse files
committed
chore: add counting of downloads in resource fetcher
1 parent ac40c6f commit e594d50

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

packages/react-native-executorch/src/utils/ResourceFetcher.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ResourceSource } from '../types/common';
22
import { RnExecutorchError } from '../errors/errorUtils';
33
import { RnExecutorchErrorCode } from '../errors/ErrorCodes';
4+
import { ResourceFetcherUtils } from './ResourceFetcherUtils';
45

56
/**
67
* Adapter interface for resource fetching operations.
@@ -105,6 +106,15 @@ export class ResourceFetcher {
105106
callback: (downloadProgress: number) => void = () => {},
106107
...sources: ResourceSource[]
107108
) {
109+
for (const source of sources) {
110+
if (typeof source === 'string') {
111+
try {
112+
ResourceFetcherUtils.triggerHuggingFaceDownloadCounter(source);
113+
} catch (error) {
114+
throw error;
115+
}
116+
}
117+
}
108118
return this.getAdapter().fetch(callback, ...sources);
109119
}
110120

0 commit comments

Comments
 (0)