Permalink
Cannot retrieve contributors at this time
52 lines (52 sloc)
2.6 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@actions/artifact/lib/internal/status-reporter.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.StatusReporter = void 0; | |
const core_1 = require("@actions/core"); | |
/** | |
* Status Reporter that displays information about the progress/status of an artifact that is being uploaded or downloaded | |
* | |
* Variable display time that can be adjusted using the displayFrequencyInMilliseconds variable | |
* The total status of the upload/download gets displayed according to this value | |
* If there is a large file that is being uploaded, extra information about the individual status can also be displayed using the updateLargeFileStatus function | |
*/ | |
class StatusReporter { | |
constructor(displayFrequencyInMilliseconds) { | |
this.totalNumberOfFilesToProcess = 0; | |
this.processedCount = 0; | |
this.largeFiles = new Map(); | |
this.totalFileStatus = undefined; | |
this.displayFrequencyInMilliseconds = displayFrequencyInMilliseconds; | |
} | |
setTotalNumberOfFilesToProcess(fileTotal) { | |
this.totalNumberOfFilesToProcess = fileTotal; | |
this.processedCount = 0; | |
} | |
start() { | |
// displays information about the total upload/download status | |
this.totalFileStatus = setInterval(() => { | |
// display 1 decimal place without any rounding | |
const percentage = this.formatPercentage(this.processedCount, this.totalNumberOfFilesToProcess); | |
core_1.info(`Total file count: ${this.totalNumberOfFilesToProcess} ---- Processed file #${this.processedCount} (${percentage.slice(0, percentage.indexOf('.') + 2)}%)`); | |
}, this.displayFrequencyInMilliseconds); | |
} | |
// if there is a large file that is being uploaded in chunks, this is used to display extra information about the status of the upload | |
updateLargeFileStatus(fileName, chunkStartIndex, chunkEndIndex, totalUploadFileSize) { | |
// display 1 decimal place without any rounding | |
const percentage = this.formatPercentage(chunkEndIndex, totalUploadFileSize); | |
core_1.info(`Uploaded ${fileName} (${percentage.slice(0, percentage.indexOf('.') + 2)}%) bytes ${chunkStartIndex}:${chunkEndIndex}`); | |
} | |
stop() { | |
if (this.totalFileStatus) { | |
clearInterval(this.totalFileStatus); | |
} | |
} | |
incrementProcessedCount() { | |
this.processedCount++; | |
} | |
formatPercentage(numerator, denominator) { | |
// toFixed() rounds, so use extra precision to display accurate information even though 4 decimal places are not displayed | |
return ((numerator / denominator) * 100).toFixed(4).toString(); | |
} | |
} | |
exports.StatusReporter = StatusReporter; | |
//# sourceMappingURL=status-reporter.js.map |