remote capability check
This commit is contained in:
+3
-7
@@ -8,7 +8,7 @@ import { notify } from '../lib/notifications'
|
||||
import queryClient from '../lib/query'
|
||||
import type { fetchMountList, fetchServeList } from '../lib/rclone/api'
|
||||
import rclone from '../lib/rclone/client'
|
||||
import { SERVE_TYPES, SUPPORTS_CLEANUP, SUPPORTS_PURGE } from '../lib/rclone/constants'
|
||||
import { SERVE_TYPES } from '../lib/rclone/constants'
|
||||
import { openFullWindow } from '../lib/window'
|
||||
import { selectCurrentHost, usePersistedStore } from '../store/persisted'
|
||||
import { COMMAND_CONFIG, COMMAND_DESCRIPTIONS, COMMAND_KEYWORDS } from './constants'
|
||||
@@ -656,9 +656,7 @@ const actions: ToolbarActionDefinition[] = [
|
||||
return []
|
||||
}
|
||||
|
||||
const supportedRemotePaths = paths.filter(
|
||||
(path) => path.remoteType && SUPPORTS_CLEANUP.includes(path.remoteType)
|
||||
)
|
||||
const supportedRemotePaths = paths.filter((path) => !!path.features?.CleanUp)
|
||||
|
||||
if (supportedRemotePaths.length === 0) {
|
||||
return [createBaseResult('Cleanup', COMMAND_DESCRIPTIONS.cleanup, {}, 36)]
|
||||
@@ -878,9 +876,7 @@ const actions: ToolbarActionDefinition[] = [
|
||||
return []
|
||||
}
|
||||
|
||||
const supportedPaths = paths.filter(
|
||||
(path) => path.remoteType && SUPPORTS_PURGE.includes(path.remoteType)
|
||||
)
|
||||
const supportedPaths = paths.filter((path) => !!path.features?.Purge)
|
||||
|
||||
if (supportedPaths.length === 0) {
|
||||
return [createBaseResult('Purge', COMMAND_DESCRIPTIONS.purge, {}, 36)]
|
||||
|
||||
+7
-3
@@ -1,4 +1,5 @@
|
||||
import { sep } from '@tauri-apps/api/path'
|
||||
import type { RcloneFeatures } from '../types/rclone'
|
||||
import { getToolbarAction, getToolbarActions } from './actions'
|
||||
import type {
|
||||
ToolbarActionArgs,
|
||||
@@ -22,13 +23,14 @@ export interface ResolvedToolbarResult {
|
||||
export function runToolbarEngine(
|
||||
query: string,
|
||||
remotes: string[],
|
||||
remoteTypes?: Record<string, string>
|
||||
remoteTypes?: Record<string, string>,
|
||||
capabilitiesByRemote?: Record<string, RcloneFeatures>
|
||||
) {
|
||||
const actions = getToolbarActions()
|
||||
|
||||
const trimmed = query.trim()
|
||||
|
||||
const parsedPaths = extractPaths(trimmed, remotes, remoteTypes)
|
||||
const parsedPaths = extractPaths(trimmed, remotes, remoteTypes, capabilitiesByRemote)
|
||||
|
||||
const cleanedQuery = trimmed.replace(parsedPaths.map((path) => path.full).join(' '), '').trim()
|
||||
|
||||
@@ -120,7 +122,8 @@ const NON_WHITESPACE_TOKEN_REGEX = /^(\S+)/
|
||||
function extractPaths(
|
||||
input: string,
|
||||
remotes: string[],
|
||||
remoteTypes?: Record<string, string>
|
||||
remoteTypes?: Record<string, string>,
|
||||
capabilitiesByRemote?: Record<string, RcloneFeatures>
|
||||
): ToolbarActionPath[] {
|
||||
const seen = new Set<string>()
|
||||
const results: ToolbarActionPath[] = []
|
||||
@@ -178,6 +181,7 @@ function extractPaths(
|
||||
isLocal,
|
||||
remoteName,
|
||||
remoteType,
|
||||
features: remoteName ? capabilitiesByRemote?.[remoteName] : undefined,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { RcloneFeatures } from '../types/rclone'
|
||||
|
||||
export type ToolbarCommandId =
|
||||
| 'copy'
|
||||
| 'move'
|
||||
@@ -43,6 +45,9 @@ export interface ToolbarActionPath {
|
||||
isLocal: boolean
|
||||
remoteName?: string
|
||||
remoteType?: string
|
||||
// Authoritative backend capability set from `operations/fsinfo`; undefined until the probe
|
||||
// resolves (or for local paths), in which case capability-gated actions fall to their generic item.
|
||||
features?: RcloneFeatures
|
||||
}
|
||||
|
||||
export interface ToolbarActionContext {
|
||||
|
||||
Reference in New Issue
Block a user