allow version skip

Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com>
This commit is contained in:
FTCHD
2025-09-24 20:18:31 +02:00
parent cc2411acb0
commit 82ae314fdc
3 changed files with 27 additions and 3 deletions
+7 -2
View File
@@ -3,6 +3,7 @@ import { exists, mkdir, writeTextFile } from '@tauri-apps/plugin-fs'
import { fetch } from '@tauri-apps/plugin-http'
import { Command } from '@tauri-apps/plugin-shell'
import { getConfigParentFolder } from '../format'
import { usePersistedStore } from '../store'
import { DOUBLE_BACKSLASH_REGEX } from './constants'
export async function getDefaultPaths() {
@@ -227,8 +228,7 @@ export function parseRcloneVersion(output: string) {
}
}
export async function shouldUpdateRclone(type?: 'system' | 'internal') {
const versionData = await getRcloneVersion(type)
export function shouldUpdateRclone(versionData: { yours: string; latest: string } | null) {
if (!versionData?.yours) return false
if (!versionData) {
@@ -247,6 +247,11 @@ export async function shouldUpdateRclone(type?: 'system' | 'internal') {
console.log('[shouldUpdateRclone] current version:', currentVersion)
console.log('[shouldUpdateRclone] latest version:', latestVersion)
if (usePersistedStore.getState().lastSkippedVersion === currentVersion) {
console.log('[shouldUpdateRclone] current version is in the lastSkippedVersion')
return false
}
// Compare versions using the existing compareVersions function
const versionComparison = compareVersions(currentVersion, latestVersion)
if (versionComparison < 0) {
+16 -1
View File
@@ -15,6 +15,7 @@ import { openSmallWindow } from '../window'
import {
createConfigFile,
getConfigPath,
getRcloneVersion,
getSystemConfigPath,
isInternalRcloneInstalled,
isSystemRcloneInstalled,
@@ -44,7 +45,9 @@ export async function initRclone(args: string[]) {
internal = true
}
if (await shouldUpdateRclone(system ? 'system' : 'internal')) {
const rcloneVersion = await getRcloneVersion(system ? 'system' : 'internal')
if (shouldUpdateRclone(rcloneVersion)) {
console.log('[initRclone] needs update')
useStore.setState({ startupStatus: 'updating' })
@@ -65,6 +68,18 @@ export async function initRclone(args: string[]) {
code
)
useStore.setState({ startupStatus: 'error' })
const skipping = await ask(
'You are running an outdated version of the CLI that could not be updated.\n\nPlease update manually and restart Rclone UI.',
{
title: 'Error',
kind: 'error',
okLabel: 'Skip version',
cancelLabel: 'Exit',
}
)
if (skipping) {
usePersistedStore.setState({ lastSkippedVersion: rcloneVersion!.yours })
}
} else {
useStore.setState({ startupStatus: 'updated' })
}
+4
View File
@@ -115,6 +115,8 @@ interface PersistedState {
activeConfigFile: ConfigFile | null
setActiveConfigFile: (configFile: string) => void
updateConfigFile: (id: string, configFile: Partial<ConfigFile>) => void
lastSkippedVersion: string | undefined
}
const getStorage = (store: LazyStore): StateStorage => ({
@@ -264,6 +266,8 @@ export const usePersistedStore = create<PersistedState>()(
f.id === id ? { ...f, ...configFile } : f
),
})),
lastSkippedVersion: undefined,
}),
{
name: 'store',