Browse Source

storage-node: fix some comments

Mokhtar Naamani 4 years ago
parent
commit
b23daf57d2

+ 2 - 2
storage-node/packages/colossus/paths/asset/v0/{id}.js

@@ -86,7 +86,7 @@ module.exports = function (storage, runtime, ipfsHttpGatewayUrl, anonymous) {
       const sufficientBalance = await runtime.providerHasMinimumBalance(PROCESS_UPLOAD_BALANCE)
 
       if (!sufficientBalance) {
-        errorHandler(res, 'Insufficient balance to process upload!', 503)
+        errorHandler(res, 'Server has insufficient balance to process upload.', 503)
         return
       }
 
@@ -96,6 +96,7 @@ module.exports = function (storage, runtime, ipfsHttpGatewayUrl, anonymous) {
       try {
         stream = await storage.open(id, 'w')
 
+        // Wether we are aborting early because of early file detection not passing filter
         let aborted = false
 
         // Early file info detection so we can abort early on.. but we do not reject
@@ -117,7 +118,6 @@ module.exports = function (storage, runtime, ipfsHttpGatewayUrl, anonymous) {
           }
         })
 
-        // `finish` comes before `fileInfo` event if file info detection happened at end of stream.
         stream.on('finish', async () => {
           if (!aborted) {
             try {

+ 3 - 3
storage-node/packages/runtime-api/assets.js

@@ -52,14 +52,14 @@ class AssetsApi {
   }
 
   /*
-   * Return the Data Object for a contendId.
-   * Throws if object doesn't exist.
+   * Returns the Data Object for a contendId.
+   * Returns null if it doesn't exist.
    */
   async getDataObject(contentId) {
     contentId = parseContentId(contentId)
+    // check if contentId key exists in map
     const storageSize = await this.base.api.query.dataDirectory.dataByContentId.size(contentId)
     if (storageSize.eq(0)) {
-      // throw new Error(`No DataObject found for content ID: ${contentId}`)
       return null
     }
     return this.base.api.query.dataDirectory.dataByContentId(contentId)