Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified packages/cli/bin/run.cmd
100644 → 100755
Empty file.
35 changes: 20 additions & 15 deletions packages/cli/src/compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,21 +796,26 @@ export default class Compiler {
}

async _uploadToIPFS(file: { path: string; content: Buffer }) {
try {
const files = this.ipfs.addAll([file]);

// We get back async iterable
const filesIterator = files[Symbol.asyncIterator]();
// We only care about the first item, since that is the file, rest could be directories
const { value } = await filesIterator.next();

// we grab the file and pin it
const uploadedFile = value as Awaited<ReturnType<typeof this.ipfs.add>>;
await this.ipfs.pin.add(uploadedFile.cid);

return uploadedFile.cid.toString();
} catch (e) {
throw Error(`Failed to upload file to IPFS: ${e.message}`);
while (1) {
try {
const files = this.ipfs.addAll([file]);

// We get back async iterable
const filesIterator = files[Symbol.asyncIterator]();
// We only care about the first item, since that is the file, rest could be directories
const { value } = await filesIterator.next();

// we grab the file and pin it
const uploadedFile = value as Awaited<ReturnType<typeof this.ipfs.add>>;

await this.ipfs.pin.add(uploadedFile.cid);

return uploadedFile.cid.toString();
} catch (e) {
console.log('Failed to upload file to IPFS: ', [(e as any).message]);
console.log('Retrying in 4 seconds...');
await new Promise(resolve => setTimeout(resolve, 4_000));
}
}
}
}
Loading