Skip to content

Commit 7cc539b

Browse files
authored
fix: remove stale files more aggressively (#39)
1 parent c673ee0 commit 7cc539b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/index.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -873,17 +873,19 @@ export default class DownloadQueue {
873873
} else {
874874
if (this.isTaskDownloading(task)) {
875875
task.stop();
876+
}
876877

877-
if (spec && !spec.finished) {
878-
try {
879-
// There might be a partially downloaded file on disk. We need to
880-
// get rid of it in case a lazy-delete spec is revived, at which
881-
// point an existing file on disk will be taken to be a
882-
// successfully downloaded one.
883-
await RNFS.unlink(spec.path);
884-
} catch {
885-
// Expected for missing files
886-
}
878+
// Given logic in the bigger "if" above, only unfinished lazy-deletes
879+
// should pass this.
880+
if (spec && !spec.finished) {
881+
try {
882+
// There might be a partially downloaded file on disk. We need to
883+
// get rid of it in case a lazy-delete spec is revived, at which
884+
// point an existing file on disk will be taken to be a
885+
// successfully downloaded one.
886+
await RNFS.unlink(spec.path);
887+
} catch {
888+
// Expected for missing files
887889
}
888890
}
889891
}

0 commit comments

Comments
 (0)