Skip to content

Commit

Permalink
Merge pull request #22 from corca-ai/fix/clean-up
Browse files Browse the repository at this point in the history
fix: fix clean-up order
  • Loading branch information
ryuni-dev authored Jul 10, 2023
2 parents 7a2934a + a1e7986 commit 67dba3e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
17 changes: 17 additions & 0 deletions src/restore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ import {
} from '../utils/cache'

async function run(): Promise<void> {
try {
/*
clean up caches
*/
const cacheBase = core.getState('cache-base')
const cleanKey = core.getInput('clean-key')
const CLEAN_TIME = 7

if (cleanKey) {
await exec(
`/bin/bash -c "find ${cacheBase} -maxdepth 1 -name '${cleanKey}*' -type d -atime +${CLEAN_TIME} -exec rm -rf {} +"`
)
}
} catch (error) {
if (error instanceof Error) core.warning(error.message)
}

try {
const key = core.getInput('key')
const base = core.getInput('base')
Expand Down
14 changes: 1 addition & 13 deletions src/save/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,9 @@ async function run(): Promise<void> {
core.info(`,not saving cache`)
}

/*
clean up caches
*/
const cacheBase = core.getState('cache-base')
const cleanKey = core.getInput('clean-key')
const CLEAN_TIME = 7

if (cleanKey) {
await exec(
`/bin/bash -c "find ${cacheBase} -maxdepth 1 -name '${cleanKey}*' -type d -atime +${CLEAN_TIME} -exec rm -rf {} +"`
)
}
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
}
}

run()
run()

0 comments on commit 67dba3e

Please sign in to comment.