checkpoint

pull/134/head
Alex Kern 1 year ago
parent ca704ec572
commit 4cb02da415
No known key found for this signature in database
GPG Key ID: EF051FACCACBEE25

@ -6,12 +6,27 @@ import {
UploaderConnectionStatus,
} from '../types'
import { decodeMessage, Message, MessageType } from '../messages'
import { validateOffset } from '../utils/fs'
import * as t from 'io-ts'
// TODO(@kern): Test for better values
const MAX_CHUNK_SIZE = 10 * 1024 * 1024 // 10 Mi
function validateOffset(
files: UploadedFile[],
fullPath: string,
offset: number,
): UploadedFile {
const validFile = files.find(
(file) =>
(file.fullPath === fullPath || file.name === fullPath) &&
offset <= file.size,
)
if (!validFile) {
throw new Error('invalid file offset')
}
return validFile
}
export function useUploaderConnections(
peer: Peer,
files: UploadedFile[],

@ -1,17 +0,0 @@
import { UploadedFile } from '../types'
export function validateOffset(
files: UploadedFile[],
fullPath: string,
offset: number,
): UploadedFile {
const validFile = files.find(
(file) =>
(file.fullPath === fullPath || file.name === fullPath) &&
offset <= file.size,
)
if (!validFile) {
throw new Error('invalid file offset')
}
return validFile
}
Loading…
Cancel
Save