Try delete dependencies lock files and disable caching if not possible

This commit is contained in:
Paul Merlin 2020-06-15 14:22:41 +02:00
parent 26dd4cb9bb
commit 355e9c1f86
3 changed files with 27 additions and 2 deletions

2
dist/main/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/post/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -68,6 +68,17 @@ export async function cacheDependencies(): Promise<void> {
return return
} }
const locksDeleted = tryDeleteFiles([
path.resolve(cachePath, 'modules-2.lock'),
path.resolve(cachePath, 'gc.properties')
])
if (!locksDeleted) {
core.warning(
'Unable to delete dependencies lock files, try using --no-daemon, not saving cache.'
)
return
}
try { try {
await cache.saveCache([cachePath], cacheKey) await cache.saveCache([cachePath], cacheKey)
} catch (error) { } catch (error) {
@ -82,3 +93,17 @@ export async function cacheDependencies(): Promise<void> {
return return
} }
function tryDeleteFiles(filePaths: string[]): boolean {
let failure = false
for (const filePath of filePaths) {
if (fs.existsSync(filePath)) {
try {
fs.unlinkSync(filePath)
} catch (error) {
failure = true
}
}
}
return !failure
}