mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-07-07 10:35:09 +00:00
Fix downloads
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import _ from 'lodash'
|
||||
import sanitize from 'sanitize-filename'
|
||||
import { Difficulty, Instrument } from 'scan-chart'
|
||||
|
||||
import { ChartData } from './interfaces/search.interface'
|
||||
@@ -24,29 +23,6 @@ export function driveLink(fileId: string) {
|
||||
return `https://drive.google.com/open?id=${fileId}`
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns `filename` with all invalid filename characters replaced.
|
||||
*/
|
||||
export function sanitizeFilename(filename: string): string {
|
||||
const newFilename = sanitize(filename, {
|
||||
replacement: ((invalidChar: string) => {
|
||||
switch (invalidChar) {
|
||||
case '<': return '❮'
|
||||
case '>': return '❯'
|
||||
case ':': return '꞉'
|
||||
case '"': return "'"
|
||||
case '/': return '/'
|
||||
case '\\': return '⧵'
|
||||
case '|': return '⏐'
|
||||
case '?': return '?'
|
||||
case '*': return '⁎'
|
||||
default: return '_'
|
||||
}
|
||||
}),
|
||||
})
|
||||
return (newFilename === '' ? 'TODO_MAKE_UNIQUE' : newFilename)
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns `text` converted to lower case.
|
||||
*/
|
||||
|
||||
@@ -3,38 +3,25 @@
|
||||
* Represents a user's request to interact with the download system.
|
||||
*/
|
||||
export interface Download {
|
||||
action: 'add' | 'retry' | 'cancel'
|
||||
versionID: number
|
||||
data?: NewDownload // Should be defined if action === 'add'
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the data required to start downloading a single chart.
|
||||
*/
|
||||
export interface NewDownload {
|
||||
chartName: string
|
||||
artist: string
|
||||
charter: string
|
||||
// TODO
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
driveData: any
|
||||
// driveData: DriveChart & { inChartPack: boolean }
|
||||
action: 'add' | 'remove' | 'retry'
|
||||
md5: string
|
||||
chartName?: string // Should be defined if action === 'add'
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the download progress of a single chart.
|
||||
*/
|
||||
export interface DownloadProgress {
|
||||
versionID: number
|
||||
title: string
|
||||
md5: string
|
||||
chartName: string
|
||||
header: string
|
||||
description: string
|
||||
percent: number
|
||||
body: string
|
||||
percent: number | null
|
||||
type: ProgressType
|
||||
/** If `description` contains a filepath that can be clicked */
|
||||
isLink: boolean
|
||||
/** If `body` contains a filepath that can be clicked */
|
||||
isPath: boolean
|
||||
/** If the download should not appear in the total download progress */
|
||||
stale?: boolean
|
||||
}
|
||||
|
||||
export type ProgressType = 'good' | 'error' | 'cancel' | 'done'
|
||||
export type ProgressType = 'good' | 'error' | 'done' | 'cancel'
|
||||
|
||||
@@ -80,7 +80,7 @@ export interface IpcFromMainEmitEvents {
|
||||
updateAvailable: UpdateInfo | null
|
||||
updateProgress: UpdateProgress
|
||||
updateDownloaded: void
|
||||
downloadUpdated: DownloadProgress
|
||||
downloadQueueUpdate: DownloadProgress
|
||||
queueUpdated: number[]
|
||||
maximized: void
|
||||
minimized: void
|
||||
|
||||
Reference in New Issue
Block a user