Send files directly between devices over the internet - no cloud storage, no size limits.
TypeScript cross-platformdata-transferdecentralizedfile-sharingfile-transferhole-punchingopen-sourcep2ppeer-to-peerprivacyprivacy-tools
resume interrupted downloads after background
Denis Lupookovc6ed7782b0cd
diff --git a/packages/components/src/components/LinkRow/LinkRow.tsx b/packages/components/src/components/LinkRow/LinkRow.tsxindex cff75c0..9b9c0ff 100644--- a/packages/components/src/components/LinkRow/LinkRow.tsx+++ b/packages/components/src/components/LinkRow/LinkRow.tsx@@ -169,6 +169,19 @@ export function LinkRow({const clampedProgressPercent =typeof progressPercent === 'number' ? Math.max(0, Math.min(100, progressPercent)) : undefined+ const statusBadge = status ? (+ <html.div style={styles.statusGroup}>+ {status.tone === 'success' ? (+ <CheckIcon size={14} color={theme.colors.colorSuccess} />+ ) : (+ <html.div style={[styles.statusDot, statusToneStyle[status.tone ?? 'muted']]} />+ )}+ <html.p style={[styles.statusLabel, statusLabelToneStyle[status.tone ?? 'muted']]}>+ {status.label}+ </html.p>+ </html.div>+ ) : null+return (<><html.div@@ -218,40 +231,34 @@ export function LinkRow({{label}</html.p>)}- {rowSubtitle ? (- <html.p- style={[- styles.subtitle,- subtitleToneStyle[subtitleTone],- compact && styles.subtitleCompact,- subtitleWrap && styles.subtitleWrap- ]}- >- {rowSubtitle}- </html.p>- ) : null}</html.div>- {status ? (- <html.div style={styles.statusColumn}>- <html.div style={styles.statusGroup}>- {status.tone === 'success' ? (- <CheckIcon size={14} color={theme.colors.colorSuccess} />- ) : (- <html.div style={[styles.statusDot, statusToneStyle[status.tone ?? 'muted']]} />- )}+ {status?.detail ? statusBadge : null}+ </html.div>++ {rowSubtitle || status ? (+ <html.div style={styles.metaRow}>+ <html.div style={styles.text}>+ {rowSubtitle ? (<html.p- style={[styles.statusLabel, statusLabelToneStyle[status.tone ?? 'muted']]}+ style={[+ styles.subtitle,+ subtitleToneStyle[subtitleTone],+ compact && styles.subtitleCompact,+ subtitleWrap && styles.subtitleWrap+ ]}>- {status.label}+ {rowSubtitle}</html.p>- </html.div>- {status.detail ? (- <html.p style={styles.statusDetail}>{status.detail}</html.p>) : null}</html.div>- ) : null}- </html.div>+ {status?.detail ? (+ <html.p style={styles.statusDetail}>{status.detail}</html.p>+ ) : (+ statusBadge+ )}+ </html.div>+ ) : null}{clampedProgressPercent !== undefined ? (<html.div style={styles.progressTrack}>diff --git a/packages/components/src/components/LinkRow/styles.ts b/packages/components/src/components/LinkRow/styles.tsindex 79b5e43..573f2f0 100644--- a/packages/components/src/components/LinkRow/styles.ts+++ b/packages/components/src/components/LinkRow/styles.ts@@ -128,6 +128,7 @@ export const styles = css.create({overflow: 'hidden',textOverflow: 'ellipsis',whiteSpace: 'nowrap',+ lineClamp: 1,color: tokens.colorTextPrimary,fontFamily: fontTokens.fontFamilySans,fontSize: tokens.fontSizeBase,@@ -172,13 +173,6 @@ export const styles = css.create({subtitleInfo: {color: tokens.colorInfo},- statusColumn: {- display: 'flex',- flexDirection: 'column',- alignItems: 'flex-end',- gap: tokens.space05,- flexShrink: 0- },statusGroup: {display: 'flex',flexDirection: 'row',diff --git a/packages/core/src/worklet/transfer/orchestrator.ts b/packages/core/src/worklet/transfer/orchestrator.tsindex c05b914..a252a12 100644--- a/packages/core/src/worklet/transfer/orchestrator.ts+++ b/packages/core/src/worklet/transfer/orchestrator.ts@@ -43,6 +43,7 @@ import {type TransferReady,type TransferStart} from './control-channel'+import { MAX_FILES_PER_TRANSFER } from './control-validation'import { topicProof } from './topic-auth'import {createDownloadCompleteMessage,@@ -117,10 +118,12 @@ export class TransferOrchestrator implements TransferRPC {private activeTransfer: TransferStart | null = nullprivate activeTransferReady: TransferReady | null = null+ private readonly pendingServes = new Map<string, DownloadRequest[]>()private readonly pendingNonce = new Map<string, string>()private readonly authedPeers = new Set<string>()private readonly authTimers = new Map<string, ReturnType<typeof setTimeout>>()private role: TransferRole | null = null+ private interruptedDownloads: string[] = []private currentTopic: string | null = nullprivate suspended: boolean = falseprivate lifecycleQueue: Promise<unknown> = Promise.resolve()@@ -282,6 +285,7 @@ export class TransferOrchestrator implements TransferRPC {private onPeerDisconnected(peerKey: string | null, remainingCount: number): void {if (peerKey) {this.pendingNonce.delete(peerKey)+ this.pendingServes.delete(peerKey)this.authedPeers.delete(peerKey)this.clearAuthTimer(peerKey)this.recognition.onPeerDisconnected(peerKey)@@ -374,7 +378,17 @@ export class TransferOrchestrator implements TransferRPC {private serve(message: DownloadRequest, session: PeerSession): void {if (!this.authedPeers.has(session.peerKey)) {- console.warn('TransferOrchestrator: refused download from unauthenticated peer')+ if (!this.pendingNonce.has(session.peerKey)) {+ console.warn('TransferOrchestrator: refused download from unauthenticated peer')+ return+ }+ const queue = this.pendingServes.get(session.peerKey) ?? []++ if (queue.length >= MAX_FILES_PER_TRANSFER) return+ queue.push(message)++ this.pendingServes.set(session.peerKey, queue)+return}if (!session.drive) return@@ -588,6 +602,10 @@ export class TransferOrchestrator implements TransferRPC {this.authedPeers.add(session.peerKey)if (this.activeTransfer) session.controlChannel.send(this.activeTransfer)this.offerTo(session)++ const queued = this.pendingServes.get(session.peerKey)+ this.pendingServes.delete(session.peerKey)+ for (const request of queued ?? []) this.serve(request, session)}private offerTo(session: PeerSession): void {@@ -660,6 +678,8 @@ export class TransferOrchestrator implements TransferRPC {this.activeTransferReady = nullthis.currentTopic = nullthis.offerPeers.clear()+ this.pendingServes.clear()+ this.interruptedDownloads = []await this.swarm.endSession()await this.sender.reset()@@ -680,6 +700,8 @@ export class TransferOrchestrator implements TransferRPC {this.remember.reset()this.currentTopic = nullthis.offerPeers.clear()+ this.pendingServes.clear()+ this.interruptedDownloads = []await this.swarm.endSession()await this.receiver.discardPartials()}@@ -710,6 +732,7 @@ export class TransferOrchestrator implements TransferRPC {if (this.suspended) returnthis.suspended = true+ this.interruptedDownloads = this.receiver.activeDownloadIds()this.abortInFlight()this.recognition.reset()this.remember.reset()@@ -730,6 +753,12 @@ export class TransferOrchestrator implements TransferRPC {this.suspended = falsethis.discovery.start()+ const interrupted = this.interruptedDownloads+ this.interruptedDownloads = []+ for (const fileId of interrupted) {+ this.sendStatus('download-failed', { fileId, resumable: true, message: 'Interrupted' })+ }+if (!this.currentTopic) returnthis.sendStatus('joined', { peers: this.swarm.peerCount })