keep current version handling
Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com>
This commit is contained in:
+27
-4
@@ -282,6 +282,20 @@ export async function initRclone(args: string[]) {
|
||||
export async function provisionRclone() {
|
||||
console.log('[provisionRclone]')
|
||||
|
||||
const currentVersionString = await fetch('https://downloads.rclone.org/version.txt').then(
|
||||
(res) => res.text()
|
||||
)
|
||||
console.log('[provisionRclone] currentVersionString', currentVersionString)
|
||||
|
||||
const currentVersion = currentVersionString.split('v')?.[1]?.trim()
|
||||
|
||||
if (!currentVersion) {
|
||||
console.error('[provisionRclone] failed to get latest version')
|
||||
await message('Failed to get latest rclone version, please try again later.')
|
||||
return
|
||||
}
|
||||
console.log('[provisionRclone] currentVersion', currentVersion)
|
||||
|
||||
const currentPlatform = platform()
|
||||
console.log('currentPlatform', currentPlatform)
|
||||
|
||||
@@ -303,7 +317,7 @@ export async function provisionRclone() {
|
||||
return
|
||||
}
|
||||
|
||||
const downloadUrl = `https://downloads.rclone.org/rclone-current-${currentOs}-${arch}.zip`
|
||||
const downloadUrl = `https://downloads.rclone.org/v${currentVersion}/rclone-v${currentVersion}-${currentOs}-${arch}.zip`
|
||||
console.log('[provisionRclone] downloadUrl', downloadUrl)
|
||||
|
||||
const downloadedFile = await fetch(downloadUrl).then((res) => res.arrayBuffer())
|
||||
@@ -347,7 +361,11 @@ export async function provisionRclone() {
|
||||
return
|
||||
}
|
||||
|
||||
const zipPath = `${tempDirPath}/rclone/rclone-current-${currentOs}-${arch}.zip`
|
||||
const zipPath = [
|
||||
tempDirPath,
|
||||
'rclone',
|
||||
`rclone-v${currentVersion}-${currentOs}-${arch}.zip`,
|
||||
].join(sep())
|
||||
console.log('[provisionRclone] zipPath', zipPath)
|
||||
|
||||
try {
|
||||
@@ -363,7 +381,7 @@ export async function provisionRclone() {
|
||||
try {
|
||||
await invoke('unzip_file', {
|
||||
zipPath,
|
||||
outputFolder: `${tempDirPath}/rclone/rclone-ui`,
|
||||
outputFolder: `${tempDirPath}/rclone/extracted`,
|
||||
})
|
||||
console.log('[provisionRclone] successfully unzipped file')
|
||||
} catch (error) {
|
||||
@@ -373,7 +391,12 @@ export async function provisionRclone() {
|
||||
return
|
||||
}
|
||||
|
||||
const unarchivedPath = `${tempDirPath}/rclone/rclone-ui/rclone-current-${currentOs}-${arch}`
|
||||
const unarchivedPath = [
|
||||
tempDirPath,
|
||||
'rclone',
|
||||
'extracted',
|
||||
`rclone-v${currentVersion}-${currentOs}-${arch}`,
|
||||
].join(sep())
|
||||
console.log('[provisionRclone] unarchivedPath', unarchivedPath)
|
||||
|
||||
const binaryName = currentPlatform === 'windows' ? 'rclone.exe' : 'rclone'
|
||||
|
||||
Reference in New Issue
Block a user