Merge pull request #383 from lbryio/better-download-fix
Restart download monitoring in redux for pending downloads after restart
This commit is contained in:
commit
a2b8bb4828
4 changed files with 43 additions and 21 deletions
|
@ -33,7 +33,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
|
||||||
* Fixed downloading files that are deleted not being removed from the downloading list
|
* Fixed downloading files that are deleted not being removed from the downloading list
|
||||||
* Fixed download progress bar not being cleared when a downloading file is deleted
|
* Fixed download progress bar not being cleared when a downloading file is deleted
|
||||||
* Fixed refresh regression after adding scroll position to history state
|
* Fixed refresh regression after adding scroll position to history state
|
||||||
* Fixed app thinking downloads with 0 progress were downloaded after restart
|
* Fixed app not monitoring download progress on files in progress between restarts
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
*
|
*
|
||||||
|
|
|
@ -199,24 +199,34 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doDownloadFile(uri, streamInfo) {
|
export function doStartDownload(uri, outpoint) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
|
||||||
lbry
|
const { downloadingByOutpoint = {} } = state.fileInfo;
|
||||||
.file_list({ outpoint: streamInfo.outpoint, full_status: true })
|
|
||||||
.then(([fileInfo]) => {
|
if (downloadingByOutpoint[outpoint]) return;
|
||||||
|
|
||||||
|
lbry.file_list({ outpoint, full_status: true }).then(([fileInfo]) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.DOWNLOADING_STARTED,
|
type: types.DOWNLOADING_STARTED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
outpoint: streamInfo.outpoint,
|
outpoint,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatch(doUpdateLoadStatus(uri, streamInfo.outpoint));
|
dispatch(doUpdateLoadStatus(uri, outpoint));
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function doDownloadFile(uri, streamInfo) {
|
||||||
|
return function(dispatch, getState) {
|
||||||
|
const state = getState();
|
||||||
|
|
||||||
|
dispatch(doStartDownload(uri, streamInfo.outpoint));
|
||||||
|
|
||||||
lbryio
|
lbryio
|
||||||
.call("file", "view", {
|
.call("file", "view", {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { doCloseModal, doOpenModal } from "actions/app";
|
||||||
import { doFetchAvailability } from "actions/availability";
|
import { doFetchAvailability } from "actions/availability";
|
||||||
import { doOpenFileInShell, doOpenFileInFolder } from "actions/file_info";
|
import { doOpenFileInShell, doOpenFileInFolder } from "actions/file_info";
|
||||||
import { makeSelectClaimForUriIsMine } from "selectors/claims";
|
import { makeSelectClaimForUriIsMine } from "selectors/claims";
|
||||||
import { doPurchaseUri, doLoadVideo } from "actions/content";
|
import { doPurchaseUri, doLoadVideo, doStartDownload } from "actions/content";
|
||||||
import FileActions from "./view";
|
import FileActions from "./view";
|
||||||
|
|
||||||
const makeSelect = () => {
|
const makeSelect = () => {
|
||||||
|
@ -47,6 +47,7 @@ const perform = dispatch => ({
|
||||||
openModal: modal => dispatch(doOpenModal(modal)),
|
openModal: modal => dispatch(doOpenModal(modal)),
|
||||||
startDownload: uri => dispatch(doPurchaseUri(uri, "affirmPurchase")),
|
startDownload: uri => dispatch(doPurchaseUri(uri, "affirmPurchase")),
|
||||||
loadVideo: uri => dispatch(doLoadVideo(uri)),
|
loadVideo: uri => dispatch(doLoadVideo(uri)),
|
||||||
|
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(makeSelect, perform)(FileActions);
|
export default connect(makeSelect, perform)(FileActions);
|
||||||
|
|
|
@ -22,6 +22,20 @@ class FileActions extends React.PureComponent {
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
this.checkAvailability(nextProps.uri);
|
this.checkAvailability(nextProps.uri);
|
||||||
|
this.restartDownload(nextProps);
|
||||||
|
}
|
||||||
|
|
||||||
|
restartDownload(props) {
|
||||||
|
const { downloading, fileInfo, uri, restartDownload } = props;
|
||||||
|
|
||||||
|
if (
|
||||||
|
!downloading &&
|
||||||
|
fileInfo &&
|
||||||
|
!fileInfo.written_bytes &&
|
||||||
|
fileInfo.written_bytes < fileInfo.total_bytes
|
||||||
|
) {
|
||||||
|
restartDownload(uri, fileInfo.outpoint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkAvailability(uri) {
|
checkAvailability(uri) {
|
||||||
|
@ -118,10 +132,7 @@ class FileActions extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (fileInfo === null && !downloading) {
|
||||||
(fileInfo === null || (fileInfo && fileInfo.written_bytes === 0)) &&
|
|
||||||
!downloading
|
|
||||||
) {
|
|
||||||
if (!costInfo) {
|
if (!costInfo) {
|
||||||
content = <BusyMessage message={__("Fetching cost info")} />;
|
content = <BusyMessage message={__("Fetching cost info")} />;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue