From a3661d15baac7460ed158ff9d3829a3a7cb897b9 Mon Sep 17 00:00:00 2001 From: PJ Date: Wed, 16 Feb 2022 12:54:27 +0100 Subject: [PATCH] Add logging --- packages/ipfs-api/src/server.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/ipfs-api/src/server.ts b/packages/ipfs-api/src/server.ts index a726f591..2863954b 100644 --- a/packages/ipfs-api/src/server.ts +++ b/packages/ipfs-api/src/server.ts @@ -7,7 +7,7 @@ import { Collection } from "mongodb"; import { API_HOSTNAME, API_PORT, MONGO_CONNECTIONSTRING, MONGO_DBNAME, UPLOAD_PATH } from "./consts"; import { MongoDB } from "./mongodb"; import { IRecord } from "./types"; -import { contentType, download, extractArchive, isDirectory, uploadDirectory, uploadFile } from "./utils"; +import { contentType, download, extractArchive, isDirectory, sleep, uploadDirectory, uploadFile } from "./utils"; require("dotenv").config(); @@ -130,8 +130,11 @@ async function reuploadFile(cid: string, recordsDB: Collection): Promis throw error; } + // sleep 3s + // TODO: hacky addition because I saw some 0-byte uploads + await sleep(3000) const fileStats = fs.statSync(filePath) - console.log('file stats', fileStats) + console.log('file size', fileStats.size) // upload the file let skylink; @@ -149,7 +152,7 @@ async function reuploadFile(cid: string, recordsDB: Collection): Promis // update record await recordsDB.updateOne({ cid }, { $set: { skylink } }); - console.log('database updated') + console.log('database updated', skylink) return skylink; }