Fix missing repeated words bug and incorrect gate

This commit is contained in:
Oliver Blanthorn 2021-03-13 13:22:26 +01:00
parent df67b1c2ff
commit 28b3c3d255
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -904,25 +904,31 @@ export async function restart() {
export async function saveas(...args: string[]) { export async function saveas(...args: string[]) {
let overwrite = false let overwrite = false
let cleanup = false let cleanup = false
const uniqueArgs = new Set(args)
if (uniqueArgs.has("--overwrite")) { const argParse = (args: string[]): string[] => {
if (args[0] === "--overwrite") {
overwrite = true overwrite = true
uniqueArgs.delete("--overwrite") args.shift()
argParse(args)
} }
if (uniqueArgs.has("--cleanup")) { if (args[0] === "--cleanup") {
cleanup = true cleanup = true
uniqueArgs.delete("--cleanup") args.shift()
argParse(args)
}
return args
} }
const requiredNativeMessengerVersion = "0.3.0" const file = argParse(args).join(" ") || undefined
if ((overwrite || cleanup) && (await Native.nativegate(requiredNativeMessengerVersion, false))) {
const requiredNativeMessengerVersion = "0.3.2"
if ((overwrite || cleanup) && !(await Native.nativegate(requiredNativeMessengerVersion, false))) {
throw new Error(`":saveas --{overwrite, cleanup}" requires native ${requiredNativeMessengerVersion} or later`) throw new Error(`":saveas --{overwrite, cleanup}" requires native ${requiredNativeMessengerVersion} or later`)
} }
if (args.length > 0) { if (args.length > 0) {
const filename = await Messaging.message("download_background", "downloadUrlAs", window.location.href, [...uniqueArgs].join(" "), overwrite, cleanup) const filename = await Messaging.message("download_background", "downloadUrlAs", window.location.href, file, overwrite, cleanup)
return fillcmdline_tmp(10000, `Download completed: ${filename} stored in ${Array.from(uniqueArgs).join(" ")}`) return fillcmdline_tmp(10000, `Download completed: ${filename} stored in ${file}`)
} else { } else {
return Messaging.message("download_background", "downloadUrl", window.location.href, true) return Messaging.message("download_background", "downloadUrl", window.location.href, true)
} }