Skip to content

Commit

Permalink
Allow pinning again
Browse files Browse the repository at this point in the history
  • Loading branch information
MHHukiewitz committed Dec 20, 2023
1 parent 192f481 commit 3139398
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/messages/store/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,22 @@ export async function Publish({
if (fileObject && fileHash) throw new Error("You can't pin a file and upload it at the same time.");
if (fileHash && storageEngine !== ItemType.ipfs) throw new Error("You must choose ipfs to pin the file.");

const fileBuffer = await processFileObject(fileObject);
const myHash = await getHash(fileBuffer, storageEngine, fileHash, APIServer);
let hash: string | undefined = fileHash;
let buffer: Buffer | undefined = undefined;
if (!hash) {
buffer = await processFileObject(fileObject);
hash = await getHash(buffer, storageEngine, fileHash, APIServer);
}

const message = await createAndSendStoreMessage(
account,
channel,
myHash,
hash,
storageEngine,
APIServer,
inlineRequested,
sync,
fileBuffer,
buffer,
);

return message;
Expand Down Expand Up @@ -101,7 +105,7 @@ async function createAndSendStoreMessage(
APIServer: string,
inlineRequested: boolean,
sync: boolean,
fileObject: Buffer,
fileObject: Buffer | undefined,
) {
const timestamp = Date.now() / 1000;
const storeContent: StoreContent = {
Expand Down

0 comments on commit 3139398

Please sign in to comment.