Merge pull request #1460 from dpalou/MOBILE-2523

MOBILE-2523 media: Fix NOT_FOUND_ERR when opening big media files
main
Juan Leyva 2018-08-22 11:29:53 +01:00 committed by GitHub
commit 0dd54379a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 18 deletions

View File

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