Fix issue file_list call continues indefinitely if a file is removed while downloading
This commit is contained in:
parent
9db8a571dd
commit
208bafdae9
1 changed files with 12 additions and 12 deletions
|
@ -3,10 +3,7 @@ import * as NOTIFICATION_TYPES from 'constants/notification_types';
|
||||||
import { ipcRenderer } from 'electron';
|
import { ipcRenderer } from 'electron';
|
||||||
import { doAlertError } from 'redux/actions/app';
|
import { doAlertError } from 'redux/actions/app';
|
||||||
import { doNavigate } from 'redux/actions/navigation';
|
import { doNavigate } from 'redux/actions/navigation';
|
||||||
import {
|
import { setSubscriptionLatest, setSubscriptionNotification } from 'redux/actions/subscriptions';
|
||||||
setSubscriptionLatest,
|
|
||||||
setSubscriptionNotification,
|
|
||||||
} from 'redux/actions/subscriptions';
|
|
||||||
import { selectNotifications } from 'redux/selectors/subscriptions';
|
import { selectNotifications } from 'redux/selectors/subscriptions';
|
||||||
import { selectBadgeNumber } from 'redux/selectors/app';
|
import { selectBadgeNumber } from 'redux/selectors/app';
|
||||||
import {
|
import {
|
||||||
|
@ -18,6 +15,7 @@ import {
|
||||||
doFetchClaimListMine,
|
doFetchClaimListMine,
|
||||||
makeSelectCostInfoForUri,
|
makeSelectCostInfoForUri,
|
||||||
makeSelectFileInfoForUri,
|
makeSelectFileInfoForUri,
|
||||||
|
selectFileInfosByOutpoint,
|
||||||
selectDownloadingByOutpoint,
|
selectDownloadingByOutpoint,
|
||||||
selectTotalDownloadProgress,
|
selectTotalDownloadProgress,
|
||||||
selectBalance,
|
selectBalance,
|
||||||
|
@ -31,17 +29,22 @@ import analytics from 'analytics';
|
||||||
|
|
||||||
const DOWNLOAD_POLL_INTERVAL = 250;
|
const DOWNLOAD_POLL_INTERVAL = 250;
|
||||||
|
|
||||||
export function doUpdateLoadStatus(uri, outpoint) {
|
export function doUpdateLoadStatus(uri: string, outpoint: string) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
|
const setNextStatusUpdate = () =>
|
||||||
|
setTimeout(() => {
|
||||||
|
const byOutpoint = selectFileInfosByOutpoint(getState());
|
||||||
|
if (byOutpoint[outpoint]) {
|
||||||
|
dispatch(doUpdateLoadStatus(uri, outpoint));
|
||||||
|
}
|
||||||
|
}, DOWNLOAD_POLL_INTERVAL);
|
||||||
Lbry.file_list({
|
Lbry.file_list({
|
||||||
outpoint,
|
outpoint,
|
||||||
full_status: true,
|
full_status: true,
|
||||||
}).then(([fileInfo]) => {
|
}).then(([fileInfo]) => {
|
||||||
if (!fileInfo || fileInfo.written_bytes === 0) {
|
if (!fileInfo || fileInfo.written_bytes === 0) {
|
||||||
// download hasn't started yet
|
// download hasn't started yet
|
||||||
setTimeout(() => {
|
setNextStatusUpdate();
|
||||||
dispatch(doUpdateLoadStatus(uri, outpoint));
|
|
||||||
}, DOWNLOAD_POLL_INTERVAL);
|
|
||||||
} else if (fileInfo.completed) {
|
} else if (fileInfo.completed) {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
// TODO this isn't going to get called if they reload the client before
|
// TODO this isn't going to get called if they reload the client before
|
||||||
|
@ -124,10 +127,7 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
||||||
|
|
||||||
const totalProgress = selectTotalDownloadProgress(getState());
|
const totalProgress = selectTotalDownloadProgress(getState());
|
||||||
setProgressBar(totalProgress);
|
setProgressBar(totalProgress);
|
||||||
|
setNextStatusUpdate();
|
||||||
setTimeout(() => {
|
|
||||||
dispatch(doUpdateLoadStatus(uri, outpoint));
|
|
||||||
}, DOWNLOAD_POLL_INTERVAL);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue