Skip to content

Commit bd67f75

Browse files
committed
Merge pull request #393 from dpalou/MOBILE-1408-new
Mobile 1408 new
2 parents 84b028d + 5aadbd1 commit bd67f75

File tree

9 files changed

+422
-98
lines changed

9 files changed

+422
-98
lines changed

upgrade.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ information provided here is intended especially for developers.
44
=== 2.9 ===
55

66
* Most of the functions from $mmaModScormOnline, $mmaModScormOffline, $mmaModScorm, $mmaModScormSync and $mmaModScormHelper now have a new param siteId to determine the site to affect. If you use any of these services please make sure you still pass the right parameters.
7+
* Now filepool tries to use the files names instead of just using a hash. If you used the functions "getFilePathByUrl" or "getDirectoryUrlByUrl" to store package files, you should now use "getPackageDirPathByUrl" and "getPackageDirUrlByUrl" instead.
78

89
=== 2.8 ===
910

www/addons/mod_imscp/services/imscp.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ angular.module('mm.addons.mod_imscp')
144144
revision = $mmFilepool.getRevisionFromFileList(module.contents),
145145
timemod = $mmFilepool.getTimemodifiedFromFileList(module.contents);
146146

147-
return $mmFilepool.getFilePathByUrl($mmSite.getId(), module.url).then(function(dirPath) {
147+
return $mmFilepool.getPackageDirPathByUrl($mmSite.getId(), module.url).then(function(dirPath) {
148148
return $mmFilepool.downloadPackage($mmSite.getId(), files, mmaModImscpComponent, module.id, revision, timemod, dirPath);
149149
});
150150
};
@@ -267,7 +267,7 @@ angular.module('mm.addons.mod_imscp')
267267
}
268268
mainFilePath = toc[0].href;
269269

270-
return $mmFilepool.getDirectoryUrlByUrl($mmSite.getId(), module.url).then(function(dirPath) {
270+
return $mmFilepool.getPackageDirUrlByUrl($mmSite.getId(), module.url).then(function(dirPath) {
271271
currentDirPath = dirPath;
272272
// This URL is going to be injected in an iframe, we need trustAsResourceUrl to make it work in a browser.
273273
return $sce.trustAsResourceUrl($mmFS.concatenatePaths(dirPath, mainFilePath));
@@ -390,7 +390,7 @@ angular.module('mm.addons.mod_imscp')
390390
revision = $mmFilepool.getRevisionFromFileList(module.contents),
391391
timemod = $mmFilepool.getTimemodifiedFromFileList(module.contents);
392392

393-
return $mmFilepool.getFilePathByUrl($mmSite.getId(), module.url).then(function(dirPath) {
393+
return $mmFilepool.getPackageDirPathByUrl($mmSite.getId(), module.url).then(function(dirPath) {
394394
return $mmFilepool.prefetchPackage($mmSite.getId(), files, mmaModImscpComponent, module.id, revision, timemod, dirPath);
395395
});
396396
};

www/addons/mod_resource/services/resource.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ angular.module('mm.addons.mod_resource')
4545

4646
if (self.isDisplayedInIframe(module)) {
4747
// Get path of the module folder in filepool.
48-
promise = $mmFilepool.getFilePathByUrl(siteid, module.url);
48+
promise = $mmFilepool.getPackageDirPathByUrl(siteid, module.url);
4949
} else {
5050
promise = $q.when();
5151
}
@@ -153,7 +153,7 @@ angular.module('mm.addons.mod_resource')
153153
mainFilePath = mainFile.filepath.substr(1) + mainFilePath;
154154
}
155155

156-
return $mmFilepool.getDirectoryUrlByUrl($mmSite.getId(), module.url).then(function(dirPath) {
156+
return $mmFilepool.getPackageDirUrlByUrl($mmSite.getId(), module.url).then(function(dirPath) {
157157
// This URL is going to be injected in an iframe, we need trustAsResourceUrl to make it work in a browser.
158158
return $sce.trustAsResourceUrl($mmFS.concatenatePaths(dirPath, mainFilePath));
159159
}, function() {
@@ -396,7 +396,7 @@ angular.module('mm.addons.mod_resource')
396396

397397
if (self.isDisplayedInIframe(module)) {
398398
// Get path of the module folder in filepool.
399-
promise = $mmFilepool.getFilePathByUrl(siteid, module.url);
399+
promise = $mmFilepool.getPackageDirPathByUrl(siteid, module.url);
400400
} else {
401401
promise = $q.when();
402402
}

www/addons/mod_scorm/services/scorm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ angular.module('mm.addons.mod_scorm')
836836

837837
siteId = siteId || $mmSite.getId();
838838

839-
return $mmFilepool.getDirectoryUrlByUrl(siteId, scorm.moduleurl).then(function(dirPath) {
839+
return $mmFilepool.getPackageDirUrlByUrl(siteId, scorm.moduleurl).then(function(dirPath) {
840840
// This URL is going to be injected in an iframe, we need trustAsResourceUrl to make it work in a browser.
841841
return $sce.trustAsResourceUrl($mmFS.concatenatePaths(dirPath, sco.launch));
842842
});
@@ -854,7 +854,7 @@ angular.module('mm.addons.mod_scorm')
854854
*/
855855
self.getScormFolder = function(moduleUrl, siteId) {
856856
siteId = siteId || $mmSite.getId();
857-
return $mmFilepool.getFilePathByUrl(siteId, moduleUrl);
857+
return $mmFilepool.getPackageDirPathByUrl(siteId, moduleUrl);
858858
};
859859

860860
/**

www/core/lib/emulator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ angular.module('mm.core')
6565
errorCallback();
6666
} else {
6767
filePath = filePath.replace(basePath, ''); // Remove basePath from the filePath.
68+
filePath = filePath.replace(/%20/g, ' '); // Replace all %20 with spaces.
6869
$mmFS.writeFile(filePath, data.data).then(function(e) {
6970
successCallback(e);
7071
}).catch(function(error) {
@@ -81,7 +82,9 @@ angular.module('mm.core')
8182
unzip: function(source, destination, callback, progressCallback) {
8283
// Remove basePath from the source and destination.
8384
source = source.replace(basePath, '');
85+
source = source.replace(/%20/g, ' '); // Replace all %20 with spaces.
8486
destination = destination.replace(basePath, '');
87+
destination = destination.replace(/%20/g, ' '); // Replace all %20 with spaces.
8588

8689
$mmFS.readFile(source, $mmFS.FORMATARRAYBUFFER).then(function(data) {
8790
var zip = new JSZip(data),

0 commit comments

Comments
 (0)