archive.social/docs/utils/SuccessLog.md

3.0 KiB

SuccessLog

thread-keeper

Author: The Harvard Library Innovation Lab
License: MIT

SuccessLog.SuccessLog

Utility class for handling success logs. Keeps trace of the hashes of the PDFs that were generated.

Kind: static class of SuccessLog

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(identifier, why, 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
identifier string Can be an IP or access key
why string Reason for creating this archive
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