Merge pull request #1460 from dpalou/MOBILE-2523
MOBILE-2523 media: Fix NOT_FOUND_ERR when opening big media filesmain
commit
0dd54379a6
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue