attempt to use part/copy idea.

This commit is contained in:
Jordan
2025-03-14 06:54:06 -07:00
parent f0a722b3fb
commit 123933d459
7 changed files with 219 additions and 18 deletions

View File

@ -110,6 +110,10 @@ const SettingsComponent = () => {
setBytesRemaining(arg0.download_data?.totalBytesExpectedToWrite);
};
const doOnComplete = (arg0: WhisperFile) => {
setWhisperFile(arg0);
}
const doDownload = async () => {
if (!whisperModel) {
throw new Error("Could not start download because whisperModel not set.");
@ -122,8 +126,10 @@ const SettingsComponent = () => {
try {
const resumable = await whisperFile.createDownloadResumable({
onData: doSetDownloadStatus,
onComplete: doOnComplete,
});
setDownloader(resumable);
if (!resumable) throw new Error("Could not construct resumable");
await resumable.resumeAsync();
} catch (error) {
console.error("Failed to download whisper model:", error);
@ -193,7 +199,7 @@ const SettingsComponent = () => {
<Text style={styles.buttonText}>DELETE {whisperModel.toUpperCase()}</Text>
</Pressable>))
}
<Pressable onPress={doDownload} style={styles.pauseDownloadButton}>
<Pressable onPress={doDownload} style={styles.downloadButton}>
<Text style={styles.buttonText}>DOWNLOAD {whisperModel.toUpperCase()}</Text>
</Pressable>
))
@ -205,7 +211,7 @@ const SettingsComponent = () => {
</Pressable>
)
}
{bytesDone && bytesRemaining && (
{bytesDone && bytesRemaining && whisperFile?.does_part_target_exist && (
<View>
{whisperFile &&
(<Text>