mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Merge pull request #311 from Zagrios/bugfix/song-not-goes-in-custom-symlink/310
[bugfix] one click install contents not goes in custom symlinks
This commit is contained in:
@@ -6,8 +6,8 @@ import { BSLocalVersionService } from "../bs-local-version.service";
|
||||
import { InstallationLocationService } from "../installation-location.service";
|
||||
import { UtilsService } from "../utils.service";
|
||||
import crypto from "crypto";
|
||||
import { lstatSync, unlinkSync } from "fs";
|
||||
import { copySync, createReadStream } from "fs-extra";
|
||||
import { lstatSync } from "fs";
|
||||
import { copy, createReadStream, ensureDir, unlink } from "fs-extra";
|
||||
import StreamZip from "node-stream-zip";
|
||||
import { RequestService } from "../request.service";
|
||||
import sanitize from "sanitize-filename";
|
||||
@@ -252,20 +252,19 @@ export class LocalMapsManagerService {
|
||||
|
||||
const { zip, zipPath } = await this.downloadMapZip(zipUrl);
|
||||
|
||||
const mapFolderName = sanitize(`${map.id}-${map.name}`);
|
||||
|
||||
const mapPath = path.join(mapsFolder, mapFolderName);
|
||||
|
||||
if (!zip) {
|
||||
throw `Cannot download ${zipUrl}`;
|
||||
}
|
||||
|
||||
const mapFolderName = sanitize(`${map.id}-${map.name}`);
|
||||
|
||||
const mapPath = path.join(mapsFolder, mapFolderName);
|
||||
|
||||
await ensureFolderExist(mapPath);
|
||||
|
||||
await zip.extract(null, mapPath);
|
||||
await zip.close();
|
||||
|
||||
unlinkSync(zipPath);
|
||||
await unlink(zipPath);
|
||||
|
||||
const localMap = await this.loadMapInfoFromPath(mapPath);
|
||||
localMap.bsaverInfo = map;
|
||||
@@ -288,20 +287,14 @@ export class LocalMapsManagerService {
|
||||
}
|
||||
|
||||
public async oneClickDownloadMap(map: BsvMapDetail): Promise<void> {
|
||||
const downloadedMap = await this.downloadMap(map);
|
||||
|
||||
const versions = await this.localVersion.getInstalledVersions();
|
||||
const downloadedMap = await this.downloadMap(map, versions.pop());
|
||||
|
||||
for (const version of versions) {
|
||||
if (await this.versionIsLinked(version)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const versionMapsPath = await this.getMapsFolderPath(version);
|
||||
|
||||
await ensureFolderExist(versionMapsPath);
|
||||
|
||||
copySync(downloadedMap.path, path.join(versionMapsPath, path.basename(downloadedMap.path)), { overwrite: true });
|
||||
await ensureDir(versionMapsPath);
|
||||
await copy(downloadedMap.path, path.join(versionMapsPath, path.basename(downloadedMap.path)), { overwrite: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,23 +119,13 @@ export class LocalModelsManagerService {
|
||||
}
|
||||
|
||||
public async oneClickDownloadModel(model: MSModel): Promise<void> {
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
if (!model) { return; }
|
||||
|
||||
const versions = await this.localVersion.getInstalledVersions();
|
||||
|
||||
if (versions?.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fisrtVersion = versions.shift();
|
||||
|
||||
const downloaded = await lastValueFrom(this.downloadModel(model, fisrtVersion));
|
||||
const downloaded = await lastValueFrom(this.downloadModel(model, versions.pop()));
|
||||
|
||||
for (const version of versions) {
|
||||
const modelDest = path.join(await this.getModelFolderPath(model.type, version), path.basename(downloaded.data.path));
|
||||
|
||||
copyFileSync(downloaded.data.path, modelDest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,20 +178,11 @@ export class LocalPlaylistsManagerService {
|
||||
public async oneClickInstallPlaylist(bpListUrl: string): Promise<void> {
|
||||
const versions = await this.versions.getInstalledVersions();
|
||||
|
||||
const firstVersion = versions.shift();
|
||||
const fistVersionLinked = await this.maps.versionIsLinked(firstVersion);
|
||||
|
||||
const { bpListPath, mapsPath } = await this.downloadPlaylist(bpListUrl, firstVersion).toPromise();
|
||||
const { bpListPath, mapsPath } = await lastValueFrom(this.downloadPlaylist(bpListUrl, versions.pop()));
|
||||
|
||||
for (const version of versions) {
|
||||
await this.installBPListFile(bpListPath, version);
|
||||
|
||||
const versionIsLinked = await this.maps.versionIsLinked(version);
|
||||
|
||||
if (fistVersionLinked && versionIsLinked) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const mapPath of mapsPath) {
|
||||
const versionMapsFolder = await this.maps.getMapsFolderPath(version);
|
||||
const mapDest = path.join(versionMapsFolder, path.basename(mapPath));
|
||||
|
||||
Reference in New Issue
Block a user