From 208bafdae95c8f35c42478694f8e114e08c36831 Mon Sep 17 00:00:00 2001 From: Chakrit Likitkhajorn Date: Mon, 15 Oct 2018 18:27:56 +0700 Subject: [PATCH 1/3] Fix issue file_list call continues indefinitely if a file is removed while downloading --- src/renderer/redux/actions/content.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/renderer/redux/actions/content.js b/src/renderer/redux/actions/content.js index 0826e4878..0b55483f5 100644 --- a/src/renderer/redux/actions/content.js +++ b/src/renderer/redux/actions/content.js @@ -3,10 +3,7 @@ import * as NOTIFICATION_TYPES from 'constants/notification_types'; import { ipcRenderer } from 'electron'; import { doAlertError } from 'redux/actions/app'; import { doNavigate } from 'redux/actions/navigation'; -import { - setSubscriptionLatest, - setSubscriptionNotification, -} from 'redux/actions/subscriptions'; +import { setSubscriptionLatest, setSubscriptionNotification } from 'redux/actions/subscriptions'; import { selectNotifications } from 'redux/selectors/subscriptions'; import { selectBadgeNumber } from 'redux/selectors/app'; import { @@ -18,6 +15,7 @@ import { doFetchClaimListMine, makeSelectCostInfoForUri, makeSelectFileInfoForUri, + selectFileInfosByOutpoint, selectDownloadingByOutpoint, selectTotalDownloadProgress, selectBalance, @@ -31,17 +29,22 @@ import analytics from 'analytics'; const DOWNLOAD_POLL_INTERVAL = 250; -export function doUpdateLoadStatus(uri, outpoint) { +export function doUpdateLoadStatus(uri: string, outpoint: string) { return (dispatch, getState) => { + const setNextStatusUpdate = () => + setTimeout(() => { + const byOutpoint = selectFileInfosByOutpoint(getState()); + if (byOutpoint[outpoint]) { + dispatch(doUpdateLoadStatus(uri, outpoint)); + } + }, DOWNLOAD_POLL_INTERVAL); Lbry.file_list({ outpoint, full_status: true, }).then(([fileInfo]) => { if (!fileInfo || fileInfo.written_bytes === 0) { // download hasn't started yet - setTimeout(() => { - dispatch(doUpdateLoadStatus(uri, outpoint)); - }, DOWNLOAD_POLL_INTERVAL); + setNextStatusUpdate(); } else if (fileInfo.completed) { const state = getState(); // 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()); setProgressBar(totalProgress); - - setTimeout(() => { - dispatch(doUpdateLoadStatus(uri, outpoint)); - }, DOWNLOAD_POLL_INTERVAL); + setNextStatusUpdate(); } }); }; From 8258fc887eb33ed76d6b98564baf690de33ed69a Mon Sep 17 00:00:00 2001 From: Chakrit Likitkhajorn Date: Thu, 18 Oct 2018 19:38:12 +0700 Subject: [PATCH 2/3] Add changelog and comment --- CHANGELOG.md | 3 ++- src/renderer/redux/actions/content.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d27d143e..bfe6ddd06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Credit card verification messaging ([#2025](https://github.com/lbryio/lbry-desktop/pull/2025)) * Reverse Order & Use System/Location Time/Date ([#2036]https://github.com/lbryio/lbry-desktop/pull/2036) * Limit file type can be uploaded as thumbnail for publishing ([#2034](https://github.com/lbryio/lbry-desktop/pull/2034)) - * Change snackbar notification postion to bottom-left ([#2040](https://github.com/lbryio/lbry-desktop/pull/2040)) + * Change snackbar notification postion to bottom-left ([#2040](https://github.com/lbryio/lbry-desktop/pull/2040)) ### Fixed @@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * History styling on large screens and link issue with claims ([#1999](https://github.com/lbryio/lbry-desktop/pull/1999)) * Satisfy console warnings in publishForm and validation messaging ([#2010](https://github.com/lbryio/lbry-desktop/pull/2010)) * App crashing if invalid characters entered in LBRY URL ([#2026])(https://github.com/lbryio/lbry-desktop/pull/2026)) + * Fix issue file_list call continues indefinitely if a file is removed while downloading ([#2042])(https://github.com/lbryio/lbry-desktop/pull/2042)) ## [0.25.1] - 2018-09-18 diff --git a/src/renderer/redux/actions/content.js b/src/renderer/redux/actions/content.js index 0b55483f5..b656f5263 100644 --- a/src/renderer/redux/actions/content.js +++ b/src/renderer/redux/actions/content.js @@ -33,6 +33,8 @@ export function doUpdateLoadStatus(uri: string, outpoint: string) { return (dispatch, getState) => { const setNextStatusUpdate = () => setTimeout(() => { + // We need to check if outpoint still exists first because user are able to delete file (outpoint) while downloading. + // If fiel is already deleted, no point to still try update load status const byOutpoint = selectFileInfosByOutpoint(getState()); if (byOutpoint[outpoint]) { dispatch(doUpdateLoadStatus(uri, outpoint)); From a98a001e1364d824e9e74e08253b70f9fbadf07a Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 18 Oct 2018 11:23:08 -0400 Subject: [PATCH 3/3] fix typo --- src/renderer/redux/actions/content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/redux/actions/content.js b/src/renderer/redux/actions/content.js index b656f5263..62107b277 100644 --- a/src/renderer/redux/actions/content.js +++ b/src/renderer/redux/actions/content.js @@ -34,7 +34,7 @@ export function doUpdateLoadStatus(uri: string, outpoint: string) { const setNextStatusUpdate = () => setTimeout(() => { // We need to check if outpoint still exists first because user are able to delete file (outpoint) while downloading. - // If fiel is already deleted, no point to still try update load status + // If a file is already deleted, no point to still try update load status const byOutpoint = selectFileInfosByOutpoint(getState()); if (byOutpoint[outpoint]) { dispatch(doUpdateLoadStatus(uri, outpoint));