Merge pull request #369 from Zagrios/bugfix/dont-download-maps-alredy-installed-when-installing-playlist

[bugfix] Don't download map already installed when installing a playlist
This commit is contained in:
MathieuG-P
2023-12-04 17:44:16 +01:00
committed by GitHub
@@ -252,17 +252,24 @@ export class LocalMapsManagerService {
}
const zipUrl = map.versions.at(0).downloadURL;
const mapFolderName = sanitize(`${map.id}-${map.name}`);
const mapsFolder = await this.getMapsFolderPath(version);
const installedMap = await this.loadMapInfoFromPath(path.join(mapsFolder, mapFolderName)).catch(e => {
log.error("loadMapInfoFromPath", e);
return null;
});
if(map.versions.every(version => version.hash === installedMap?.hash)) {
return installedMap;
}
const { zip, zipPath } = await this.downloadMapZip(zipUrl);
if (!zip) {
throw `Cannot download ${zipUrl}`;
}
const mapFolderName = sanitize(`${map.id}-${map.name}`);
const mapPath = path.join(mapsFolder, mapFolderName);
await ensureFolderExist(mapPath);