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 download progress bar not being cleared when a downloading file is deleted
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -199,24 +199,34 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
|||
};
|
||||
}
|
||||
|
||||
export function doDownloadFile(uri, streamInfo) {
|
||||
export function doStartDownload(uri, outpoint) {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState();
|
||||
|
||||
lbry
|
||||
.file_list({ outpoint: streamInfo.outpoint, full_status: true })
|
||||
.then(([fileInfo]) => {
|
||||
const { downloadingByOutpoint = {} } = state.fileInfo;
|
||||
|
||||
if (downloadingByOutpoint[outpoint]) return;
|
||||
|
||||
lbry.file_list({ outpoint, full_status: true }).then(([fileInfo]) => {
|
||||
dispatch({
|
||||
type: types.DOWNLOADING_STARTED,
|
||||
data: {
|
||||
uri,
|
||||
outpoint: streamInfo.outpoint,
|
||||
outpoint,
|
||||
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
|
||||
.call("file", "view", {
|
||||
|
|
|
@ -13,7 +13,7 @@ import { doCloseModal, doOpenModal } from "actions/app";
|
|||
import { doFetchAvailability } from "actions/availability";
|
||||
import { doOpenFileInShell, doOpenFileInFolder } from "actions/file_info";
|
||||
import { makeSelectClaimForUriIsMine } from "selectors/claims";
|
||||
import { doPurchaseUri, doLoadVideo } from "actions/content";
|
||||
import { doPurchaseUri, doLoadVideo, doStartDownload } from "actions/content";
|
||||
import FileActions from "./view";
|
||||
|
||||
const makeSelect = () => {
|
||||
|
@ -47,6 +47,7 @@ const perform = dispatch => ({
|
|||
openModal: modal => dispatch(doOpenModal(modal)),
|
||||
startDownload: uri => dispatch(doPurchaseUri(uri, "affirmPurchase")),
|
||||
loadVideo: uri => dispatch(doLoadVideo(uri)),
|
||||
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
|
||||
});
|
||||
|
||||
export default connect(makeSelect, perform)(FileActions);
|
||||
|
|
|
@ -22,6 +22,20 @@ class FileActions extends React.PureComponent {
|
|||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
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) {
|
||||
|
@ -118,10 +132,7 @@ class FileActions extends React.PureComponent {
|
|||
/>
|
||||
</div>
|
||||
);
|
||||
} else if (
|
||||
(fileInfo === null || (fileInfo && fileInfo.written_bytes === 0)) &&
|
||||
!downloading
|
||||
) {
|
||||
} else if (fileInfo === null && !downloading) {
|
||||
if (!costInfo) {
|
||||
content = <BusyMessage message={__("Fetching cost info")} />;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue