Merge pull request #3095 from dpalou/MOBILE-3833

MOBILE-3833 core: Fix infinite requests if file download failed
main
Pau Ferrer Ocaña 2022-02-04 11:20:28 +01:00 committed by GitHub
commit 46f82b58be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -25,7 +25,7 @@ import {
} from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreFile } from '@services/file';
import { CoreFilepool } from '@services/filepool';
import { CoreFilepool, CoreFilepoolFileActions, CoreFilepoolFileEventData } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUrlUtils } from '@services/utils/url';
@ -395,7 +395,12 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges, O
// Listen for download changes in the file.
const eventName = await CoreFilepool.getFileEventNameByUrl(site.getId(), url);
this.fileEventObserver = CoreEvents.on(eventName, async () => {
this.fileEventObserver = CoreEvents.on(eventName, async (data: CoreFilepoolFileEventData) => {
if (data.action === CoreFilepoolFileActions.DOWNLOAD && !data.success) {
// Error downloading the file. Don't try again.
return;
}
const newState = await CoreFilepool.getFileStateByUrl(site.getId(), url);
if (newState === state) {
return;

View File

@ -1251,7 +1251,7 @@ export class CoreFilepoolProvider {
}
/**
* Get the name of the event used to notify download events (CoreEventsProvider).
* Get the name of the event used to notify download events.
*
* @param siteId The site ID.
* @param fileId The file ID.
@ -1262,7 +1262,7 @@ export class CoreFilepoolProvider {
}
/**
* Get the name of the event used to notify download events (CoreEventsProvider).
* Get the name of the event used to notify download events.
*
* @param siteId The site ID.
* @param fileUrl The absolute URL to the file.
@ -3008,7 +3008,7 @@ export class CoreFilepoolProvider {
}
/**
* Trigger mmCoreEventPackageStatusChanged with the right data.
* Trigger package status changed event with the right data.
*
* @param siteId Site ID.
* @param status New package status.