archive.social/docs/utils/SuccessLog.md

3.0 KiB

logCaptureSuccess

archive.social

Author: The Harvard Library Innovation Lab
License: MIT

logCaptureSuccess.SuccessLog

Kind: static class of logCaptureSuccess

new exports.SuccessLog()

On init:

  • Create log file if it doesn't exist
  • Load hashes from file into this.#hashes.

successLog.filepath : string

Complete path to success-log.json.

Kind: instance property of SuccessLog

successLog.add(accessKey, pdfBytes)

Calculates hash of a PDF an:

  • Creates a success log entry
  • Updates this.#hashes (so it doesn't need to reload from file)

Kind: instance method of SuccessLog

Param Type Description
accessKey string
pdfBytes Buffer Used to store a SHA512 hash of the PDF that was delivered

successLog.findHashInLogs(hash) ⇒ boolean

Checks whether or not a given hash is present in the logs.

Kind: instance method of SuccessLog

Param Type
hash string

successLog.reset() ⇒ void

Resets success-log.json. Also clears this.#hashes.

Kind: instance method of SuccessLog