Merge pull request #2498 from dpalou/MOBILE-3453
MOBILE-3453 h5p: Don't unpack more than one H5P at the same timemain
commit
ec303acfcd
|
@ -146,12 +146,29 @@ export class CoreH5PHelper {
|
|||
static async saveH5P(fileUrl: string, file: FileEntry, siteId?: string, onProgress?: (event: any) => any): Promise<void> {
|
||||
siteId = siteId || CoreSites.instance.getCurrentSiteId();
|
||||
|
||||
const folderName = CoreMimetypeUtils.instance.removeExtension(file.name);
|
||||
const destFolder = CoreTextUtils.instance.concatenatePaths(CoreFileProvider.TMPFOLDER, 'h5p/' + folderName);
|
||||
|
||||
// Notify that the unzip is starting.
|
||||
onProgress && onProgress({message: 'core.unzipping'});
|
||||
|
||||
const queueId = siteId + ':saveH5P:' + fileUrl;
|
||||
|
||||
await CoreH5P.instance.queueRunner.run(queueId, () => CoreH5PHelper.performSave(fileUrl, file, siteId, onProgress));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract and store an H5P file.
|
||||
*
|
||||
* @param fileUrl The file URL used to download the file.
|
||||
* @param file The file entry of the downloaded file.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @param onProgress Function to call on progress.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected static async performSave(fileUrl: string, file: FileEntry, siteId?: string, onProgress?: (event: any) => any)
|
||||
: Promise<void> {
|
||||
|
||||
const folderName = CoreMimetypeUtils.instance.removeExtension(file.name);
|
||||
const destFolder = CoreTextUtils.instance.concatenatePaths(CoreFileProvider.TMPFOLDER, 'h5p/' + folderName);
|
||||
|
||||
// Unzip the file.
|
||||
await CoreFile.instance.unzipFile(file.toURL(), destFolder, onProgress);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
|||
import { CoreWSExternalWarning, CoreWSExternalFile } from '@providers/ws';
|
||||
import { CoreTextUtils } from '@providers/utils/text';
|
||||
import { CoreUrlUtils } from '@providers/utils/url';
|
||||
import { CoreQueueRunner } from '@classes/queue-runner';
|
||||
|
||||
import { CoreH5PCore } from '../classes/core';
|
||||
import { CoreH5PFramework } from '../classes/framework';
|
||||
|
@ -46,6 +47,7 @@ export class CoreH5PProvider {
|
|||
h5pPlayer: CoreH5PPlayer;
|
||||
h5pStorage: CoreH5PStorage;
|
||||
h5pValidator: CoreH5PValidator;
|
||||
queueRunner: CoreQueueRunner;
|
||||
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreH5PProvider',
|
||||
|
@ -271,6 +273,7 @@ export class CoreH5PProvider {
|
|||
constructor() {
|
||||
|
||||
this.logger = CoreLogger.instance.getInstance('CoreH5PProvider');
|
||||
this.queueRunner = new CoreQueueRunner(1);
|
||||
|
||||
CoreSites.instance.registerSiteSchema(this.siteSchema);
|
||||
|
||||
|
|
Loading…
Reference in New Issue