Skip to content

Commit

Permalink
feat: renterd multipart upload manager
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Feb 23, 2024
1 parent 5c77c0e commit f9800c8
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 96 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-garlics-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

File uploads now use multipart uploads.
5 changes: 5 additions & 0 deletions .changeset/pretty-roses-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

File uploads now have a max concurrency and get queued.
5 changes: 3 additions & 2 deletions apps/renterd/components/TransfersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { useState } from 'react'
import { useFilesManager } from '../contexts/filesManager'
import { useAppSettings } from '@siafoundation/react-core'
import { upperFirst } from '@technically/lodash'

function getProgress(transfer: { loaded?: number; size?: number }) {
return transfer.loaded !== undefined ? transfer.loaded / transfer.size : 1
Expand Down Expand Up @@ -56,7 +57,7 @@ export function TransfersBar() {
const progress = getProgress(upload)
return (
<div
key={upload.path}
key={upload.id}
className="flex flex-col gap-1 border-t first:border-t-0 border-gray-200 dark:border-graydark-300 px-3 py-2"
>
<div className="flex gap-1">
Expand All @@ -80,7 +81,7 @@ export function TransfersBar() {
/>
<div className="flex justify-between mt-1">
<Text size="12" color="subtle">
{progress === 1 ? 'Processing' : 'Uploading'}
{upperFirst(upload.uploadStatus)}
</Text>
<Text size="12" color="subtle">
{(progress * 100).toFixed(0)}%
Expand Down
16 changes: 16 additions & 0 deletions apps/renterd/contexts/filesManager/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Bucket } from '@siafoundation/react-renterd'
import { FullPath } from '../../lib/paths'
import { TableColumn } from '@siafoundation/design-system'
import { MultipartUpload } from '../../lib/multipartUpload'

export type ObjectType = 'bucket' | 'directory' | 'file'

Expand Down Expand Up @@ -78,3 +79,18 @@ export const sortOptions: { id: SortField; label: string; category: string }[] =
]

export type ExplorerMode = 'directory' | 'flat'

export type UploadStatus = 'queued' | 'uploading' | 'processing'

export type ObjectUploadData = ObjectData & {
upload: MultipartUpload
uploadStatus: UploadStatus
uploadAbort?: () => void
uploadFile?: File
}

export type ObjectUploadRemoteData = ObjectData & {
remote: true
}

export type UploadsMap = Record<string, ObjectUploadData>
Loading

0 comments on commit f9800c8

Please sign in to comment.