MOBILE-2523 media: Fix NOT_FOUND_ERR when opening big media files

main
Dani Palou 2018-08-07 12:07:00 +02:00
parent e6c5607463
commit 7924dadcfb
1 changed files with 22 additions and 18 deletions

View File

@ -62,29 +62,33 @@ export class CoreFileHelperProvider {
return Promise.reject(error);
}
// Get the state.
if (state) {
return state;
} else {
return this.filepoolProvider.getFileStateByUrl(siteId, fileUrl, timemodified);
}
}).then((state) => {
if (state == CoreConstants.DOWNLOADING) {
return Promise.reject(this.translate.instant('core.erroropenfiledownloading'));
}
let promise;
if (state === CoreConstants.NOT_DOWNLOADED) {
// File is not downloaded, download and then return the local URL.
promise = this.downloadFile(fileUrl, component, componentId, timemodified, onProgress, file, siteId);
// Get the state.
if (state) {
promise = Promise.resolve(state);
} else {
// File is outdated and can't be opened in online, return the local URL.
promise = this.filepoolProvider.getInternalUrlByUrl(siteId, fileUrl);
promise = this.filepoolProvider.getFileStateByUrl(siteId, fileUrl, timemodified);
}
return promise.then((url) => {
return this.utils.openFile(url);
return promise.then((state) => {
if (state == CoreConstants.DOWNLOADING) {
return Promise.reject(this.translate.instant('core.erroropenfiledownloading'));
}
let promise;
if (state === CoreConstants.NOT_DOWNLOADED) {
// File is not downloaded, download and then return the local URL.
promise = this.downloadFile(fileUrl, component, componentId, timemodified, onProgress, file, siteId);
} else {
// File is outdated and can't be opened in online, return the local URL.
promise = this.filepoolProvider.getInternalUrlByUrl(siteId, fileUrl);
}
return promise.then((url) => {
return this.utils.openFile(url);
});
});
});
} else {