Skip to content

Commit

Permalink
Add directory size to tmp track artifacts deletion logs (#4191)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaylor89 committed Oct 26, 2022
1 parent 4a374fd commit 6e79f1d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions creator-node/src/diskManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,25 @@ class DiskManager {
return config.get('storagePath')
}

/**
*
* @param {string} path the path to get the size for
* @returns the string output of stdout
*/
static async getDirSize(path) {
const stdout = await this._execShellCommand(`du -sh ${path}`)
return stdout
}

/**
* Empties the tmp track artifacts directory of any old artifacts
*/
static async emptyTmpTrackUploadArtifacts() {
const dirPath = await this.getTmpTrackUploadArtifactsPath()
const dirSize = await this.getDirSize(dirPath)
await fs.emptyDir(dirPath)

return dirSize
}

/**
Expand Down
6 changes: 4 additions & 2 deletions creator-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ const startAppForPrimary = async () => {
await setupDbAndRedis()

const startTime = Date.now()
await DiskManager.emptyTmpTrackUploadArtifacts()
const size = await DiskManager.emptyTmpTrackUploadArtifacts()
logger.info(
`old tmp track artifacts deleted : ${(Date.now() - startTime) / 1000}sec`
`old tmp track artifacts deleted : ${size} : ${
(Date.now() - startTime) / 1000
}sec`
)

// Don't await - run in background. Remove after v0.3.69
Expand Down

0 comments on commit 6e79f1d

Please sign in to comment.