diff --git a/apps/renterd/components/Files/FilesCmd/FilesSearchCmd/index.tsx b/apps/renterd/components/Files/FilesCmd/FilesSearchCmd/index.tsx index e68dd67a4..3b4153d9b 100644 --- a/apps/renterd/components/Files/FilesCmd/FilesSearchCmd/index.tsx +++ b/apps/renterd/components/Files/FilesCmd/FilesSearchCmd/index.tsx @@ -1,6 +1,6 @@ import { CommandGroup, CommandItemSearch } from '../../../CmdRoot/Item' import { Page } from '../../../CmdRoot/types' -import { useObjectList } from '@siafoundation/renterd-react' +import { useObjects } from '@siafoundation/renterd-react' import { isDirectory } from '../../../../lib/paths' import { Text } from '@siafoundation/design-system' import { Document16, FolderIcon } from '@siafoundation/react-icons' @@ -31,7 +31,7 @@ export function FilesSearchCmd({ useFilesManager() const onSearchPage = currentPage?.namespace === filesSearchPage.namespace const searchBucket = activeBucket || 'default' - const results = useObjectList({ + const results = useObjects({ disabled: !onSearchPage, params: { bucket: searchBucket, diff --git a/apps/renterd/contexts/filesDirectory/dataset.tsx b/apps/renterd/contexts/filesDirectory/dataset.tsx index 928761f04..9fdf32e7d 100644 --- a/apps/renterd/contexts/filesDirectory/dataset.tsx +++ b/apps/renterd/contexts/filesDirectory/dataset.tsx @@ -1,11 +1,11 @@ -import { useObjectList } from '@siafoundation/renterd-react' +import { useObjects } from '@siafoundation/renterd-react' import { useDataset as useDatasetGeneric } from '../filesManager/dataset' import { bucketAndKeyParamsFromPath } from '../../lib/paths' import { useRouter } from 'next/router' import { useMemo } from 'react' import { useFilesManager } from '../filesManager' import { defaultDatasetRefreshInterval } from '../../config/swr' -import { ObjectListParams } from '@siafoundation/renterd-types' +import { ObjectsParams } from '@siafoundation/renterd-types' const defaultLimit = 50 @@ -30,7 +30,7 @@ export function useDataset() { ? fileNamePrefixFilter.slice(1) : fileNamePrefixFilter } - const p: ObjectListParams = { + const p: ObjectsParams = { prefix, bucket: pathParams.bucket, sortBy: sortField, @@ -51,7 +51,7 @@ export function useDataset() { limit, ]) - const response = useObjectList({ + const response = useObjects({ disabled: !activeBucketName, params, config: { diff --git a/apps/renterd/contexts/filesFlat/dataset.tsx b/apps/renterd/contexts/filesFlat/dataset.tsx index 212eb8d72..60e86adfb 100644 --- a/apps/renterd/contexts/filesFlat/dataset.tsx +++ b/apps/renterd/contexts/filesFlat/dataset.tsx @@ -1,11 +1,11 @@ -import { useObjectList } from '@siafoundation/renterd-react' +import { useObjects } from '@siafoundation/renterd-react' import { SortField } from '../filesManager/types' import { useDataset as useDatasetGeneric } from '../filesManager/dataset' import { useRouter } from 'next/router' import { useMemo } from 'react' import { useFilesManager } from '../filesManager' import { defaultDatasetRefreshInterval } from '../../config/swr' -import { ObjectListParams } from '@siafoundation/renterd-types' +import { ObjectsParams } from '@siafoundation/renterd-types' type Props = { sortDirection: 'asc' | 'desc' @@ -27,7 +27,7 @@ export function useDataset({ sortDirection, sortField }: Props) { ? fileNamePrefixFilter.slice(1) : fileNamePrefixFilter } - const p: ObjectListParams = { + const p: ObjectsParams = { prefix, bucket: activeBucketName, sortBy: sortField, @@ -48,7 +48,7 @@ export function useDataset({ sortDirection, sortField }: Props) { limit, ]) - const response = useObjectList({ + const response = useObjects({ disabled: !activeBucketName, params, config: { diff --git a/apps/renterd/contexts/filesManager/uploads.tsx b/apps/renterd/contexts/filesManager/uploads.tsx index 4fbc8643c..33deb0215 100644 --- a/apps/renterd/contexts/filesManager/uploads.tsx +++ b/apps/renterd/contexts/filesManager/uploads.tsx @@ -8,7 +8,7 @@ import { useMultipartUploadPart, useSettingsUpload, } from '@siafoundation/renterd-react' -import { Bucket, busListObjectsRoute } from '@siafoundation/renterd-types' +import { Bucket, busObjectsRoute } from '@siafoundation/renterd-types' import { MiBToBytes, minutesInMilliseconds } from '@siafoundation/units' import { throttle } from '@technically/lodash' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' @@ -133,7 +133,7 @@ export function useUploads({ activeDirectoryPath }: Props) { }, 1000) ) multipartUpload.setOnComplete(async () => { - await ref.current.mutate((key) => key.startsWith(busListObjectsRoute)) + await ref.current.mutate((key) => key.startsWith(busObjectsRoute)) ref.current.removeUpload(uploadId) setTimeout(() => { ref.current.checkAndStartUploads() diff --git a/libs/renterd-js/src/bus.ts b/libs/renterd-js/src/bus.ts index 79c656f9e..d26ab6562 100644 --- a/libs/renterd-js/src/bus.ts +++ b/libs/renterd-js/src/bus.ts @@ -471,7 +471,7 @@ export function Bus({ api, password }: { api: string; password?: string }) { BucketDeletePayload, BucketDeleteResponse >(axios, 'delete', busBucketNameRoute), - objectList: buildRequestHandler< + objects: buildRequestHandler< ObjectsParams, ObjectsPayload, ObjectsResponse diff --git a/libs/renterd-js/src/worker.ts b/libs/renterd-js/src/worker.ts index b3268e1d8..98b548640 100644 --- a/libs/renterd-js/src/worker.ts +++ b/libs/renterd-js/src/worker.ts @@ -19,7 +19,7 @@ import { WorkerStateResponse, workerAccountIdResetdriftRoute, workerMultipartKeyRoute, - workerObjectsKeyRoute, + workerObjectKeyRoute, workerRhpScanRoute, workerStateRoute, } from '@siafoundation/renterd-types' @@ -38,7 +38,7 @@ export function Worker({ api, password }: { api: string; password?: string }) { ObjectDownloadParams, ObjectDownloadPayload, ObjectDownloadResponse - >(axios, 'get', workerObjectsKeyRoute, { + >(axios, 'get', workerObjectKeyRoute, { config: { responseType: 'blob', }, @@ -47,7 +47,7 @@ export function Worker({ api, password }: { api: string; password?: string }) { ObjectUploadParams, ObjectUploadPayload, ObjectUploadResponse - >(axios, 'put', workerObjectsKeyRoute, { + >(axios, 'put', workerObjectKeyRoute, { config: { headers: { 'Content-Type': 'multipart/form-data', diff --git a/libs/renterd-react/src/bus.ts b/libs/renterd-react/src/bus.ts index 6ef8a11c8..52bb41290 100644 --- a/libs/renterd-react/src/bus.ts +++ b/libs/renterd-react/src/bus.ts @@ -702,9 +702,7 @@ export function useBucketDelete( ) } -export function useObjectList( - args: HookArgsSwr -) { +export function useObjects(args: HookArgsSwr) { return useGetSwr({ ...args, route: busObjectsPrefixRoute }) } diff --git a/libs/renterd-react/src/worker.ts b/libs/renterd-react/src/worker.ts index b23ed40c5..bdb3927a1 100644 --- a/libs/renterd-react/src/worker.ts +++ b/libs/renterd-react/src/worker.ts @@ -29,10 +29,9 @@ import { busHostsRoute, workerAccountIdResetdriftRoute, workerMultipartKeyRoute, - workerObjectsKeyRoute, + workerObjectKeyRoute, workerRhpScanRoute, workerStateRoute, - busObjectsRoute, Host, } from '@siafoundation/renterd-types' @@ -54,7 +53,7 @@ export function useObjectDownloadFunc( ObjectDownloadResponse > ) { - return useGetDownloadFunc({ ...args, route: workerObjectsKeyRoute }) + return useGetDownloadFunc({ ...args, route: workerObjectKeyRoute }) } export function useObjectUpload( @@ -76,7 +75,7 @@ export function useObjectUpload( }, }, }, - route: workerObjectsKeyRoute, + route: workerObjectKeyRoute, }, async (mutate) => { mutate((key) => key.startsWith(busObjectsRoute)) diff --git a/libs/renterd-types/src/bus.ts b/libs/renterd-types/src/bus.ts index f059317b6..911449fe3 100644 --- a/libs/renterd-types/src/bus.ts +++ b/libs/renterd-types/src/bus.ts @@ -399,7 +399,7 @@ export type BucketDeletePayload = void export type BucketDeleteResponse = void export type ObjectsParams = { - bucket: string + bucket?: string prefix?: string delimiter?: string limit?: number @@ -407,7 +407,7 @@ export type ObjectsParams = { sortBy?: 'name' | 'health' | 'size' sortDir?: 'asc' | 'desc' substring?: string - slabEncryptionKey: string + slabEncryptionKey?: string } export type ObjectsPayload = void export type ObjectsResponse = { diff --git a/libs/renterd-types/src/worker.ts b/libs/renterd-types/src/worker.ts index f01bc523f..155b530dd 100644 --- a/libs/renterd-types/src/worker.ts +++ b/libs/renterd-types/src/worker.ts @@ -2,7 +2,7 @@ import { HostSettings } from './types' import { BusStateResponse } from './bus' export const workerStateRoute = '/worker/state' -export const workerObjectsKeyRoute = '/worker/objects/:key' +export const workerObjectKeyRoute = '/worker/object/:key' export const workerMultipartKeyRoute = '/worker/multipart/:key' export const workerRhpScanRoute = '/worker/rhp/scan' export const workerAccountIdResetdriftRoute = '/worker/account/:id/resetdrift'