mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Merge pull request #645 from Zagrios/bugfix/fix-oneclick-download-playlist-broken
[bugfix] Fix broken oneclick playlist download + issue with specials chars in playlists filenames
(cherry picked from commit d5f2ba3b21)
This commit is contained in:
@@ -13,6 +13,7 @@ import { BeatSaverService } from "../thrid-party/beat-saver/beat-saver.service";
|
||||
import { copy, copyFile, pathExists, realpath } from "fs-extra";
|
||||
import { Progression, ensureFolderExist, pathExist } from "../../helpers/fs.helpers";
|
||||
import { IpcService } from "../ipc.service";
|
||||
import sanitize from "sanitize-filename";
|
||||
|
||||
export class LocalPlaylistsManagerService {
|
||||
private static instance: LocalPlaylistsManagerService;
|
||||
@@ -71,12 +72,13 @@ export class LocalPlaylistsManagerService {
|
||||
private async installBPListFile(bslistSource: string, version: BSVersion): Promise<string> {
|
||||
const playlistFolder = await this.getPlaylistsFolder(version);
|
||||
const isLocalFile = await pathExists(bslistSource).catch(e => { log.error(e); return false; });
|
||||
const filename = isLocalFile ? path.basename(bslistSource) : new URL(bslistSource).pathname.split('/').pop()
|
||||
const filename = isLocalFile ? path.basename(bslistSource) : sanitize(new URL(bslistSource).pathname.split('/').pop())
|
||||
const destFile = path.join(playlistFolder, filename);
|
||||
|
||||
if (isLocalFile) {
|
||||
return copyFile(bslistSource, destFile).then(() => destFile);
|
||||
}
|
||||
|
||||
return lastValueFrom(this.request.downloadFile(bslistSource, {
|
||||
destFolder: playlistFolder,
|
||||
filename,
|
||||
|
||||
+3
-2
@@ -8,8 +8,9 @@ export function resolveHtmlPath (htmlFileName: string) {
|
||||
const url = new URL(`http://localhost:${port}/${htmlFileName}`);
|
||||
return url.toString();
|
||||
}
|
||||
const filePath = path.resolve(__dirname, "..", "renderer", htmlFileName);
|
||||
return pathToFileURL(filePath).toString();
|
||||
|
||||
const filePath = path.resolve(__dirname, "..", "renderer");
|
||||
return pathToFileURL(filePath).toString().concat("/", htmlFileName);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user