Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #138 from web3-storage/fix/fix-split-uploads
Browse files Browse the repository at this point in the history
fix: Fix issue with chunked uploads invalid origin.
  • Loading branch information
ice-breaker-tg committed Nov 11, 2022
2 parents 41fba67 + 1644ca1 commit c22c6eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/commands/car/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import toIterator from 'stream-to-it'
/**
* @typedef {object} GenerateCar
* @property {string} [filePath='']
* @property {boolean} [split=false]
* @typedef {import('yargs').Arguments<GenerateCar>} GenerateCarArgs
*/

Expand All @@ -35,7 +34,7 @@ export const writeFileLocally = async (car, outPath = 'output.car') => {
* @param {GenerateCarArgs} argv
* @returns {Promise<void>}
*/
const handler = async ({ filePath = '', split = false }) => {
const handler = async ({ filePath = '' }) => {
const resolvedPath = path.normalize(filePath)

/** @type import('ora').Options */
Expand All @@ -46,7 +45,7 @@ const handler = async ({ filePath = '', split = false }) => {
const view = ora(oraOpts).start()

try {
const { stream } = await buildCar(resolvedPath, MAX_CAR_SIZE, !split)
const { stream } = await buildCar(resolvedPath, MAX_CAR_SIZE, false)
/** @type Array<CID> */
let roots = []
/** @type CID */
Expand Down
12 changes: 3 additions & 9 deletions src/commands/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import path from 'path'
import toIterator from 'stream-to-it'

/**
* @typedef {{path?: string, split?: boolean, profile?: string}} Upload
* @typedef {{path?: string, profile?: string}} Upload
* @typedef {import('yargs').Arguments<Upload>} UploadArgs
*/

Expand Down Expand Up @@ -40,7 +40,8 @@ async function generateCarUploads (filePath, view, chunkSize = 512, profile) {
const cid = await bytesToCarCID(car.bytes)
cids.push(cid)

const result = await client.upload(car.bytes, origin?.toString())
// @ts-expect-error
const result = await client.upload(car.bytes, origin)
if (result.error) {
// @ts-expect-error
throw new Error(result?.cause?.message)
Expand Down Expand Up @@ -112,13 +113,6 @@ const builder = (yargs) =>
.option('chunk-size', {
type: 'number'
})
.option('split', {
type: 'boolean',
alias: 'split',
showInHelp: true,
describe:
'Split the data into multiple when cars when size limit is hit.'
})

export default {
// command: ['upload <path>', 'import <path>'],
Expand Down

0 comments on commit c22c6eb

Please sign in to comment.