From 82ae314fdcc1cf96b34103199039d71e99e836cd Mon Sep 17 00:00:00 2001 From: FTCHD <144691102+FTCHD@users.noreply.github.com> Date: Wed, 24 Sep 2025 20:18:31 +0200 Subject: [PATCH] allow version skip Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com> --- lib/rclone/common.ts | 9 +++++++-- lib/rclone/init.ts | 17 ++++++++++++++++- lib/store.ts | 4 ++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/rclone/common.ts b/lib/rclone/common.ts index 984bd52..f655ab8 100644 --- a/lib/rclone/common.ts +++ b/lib/rclone/common.ts @@ -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) { diff --git a/lib/rclone/init.ts b/lib/rclone/init.ts index 6984eb7..9ec9f0c 100644 --- a/lib/rclone/init.ts +++ b/lib/rclone/init.ts @@ -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' }) } diff --git a/lib/store.ts b/lib/store.ts index 679fe33..5d366c5 100644 --- a/lib/store.ts +++ b/lib/store.ts @@ -115,6 +115,8 @@ interface PersistedState { activeConfigFile: ConfigFile | null setActiveConfigFile: (configFile: string) => void updateConfigFile: (id: string, configFile: Partial) => void + + lastSkippedVersion: string | undefined } const getStorage = (store: LazyStore): StateStorage => ({ @@ -264,6 +266,8 @@ export const usePersistedStore = create()( f.id === id ? { ...f, ...configFile } : f ), })), + + lastSkippedVersion: undefined, }), { name: 'store',