Skip to content

Commit

Permalink
fix(core): make missing output check more comprehensive (#6204)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirjai authored and vsavkin committed Jul 2, 2021
1 parent 98cb4fc commit dc4270d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/workspace/src/tasks-runner/cache.ts
Expand Up @@ -8,7 +8,7 @@ import {
lstatSync,
unlinkSync,
} from 'fs';
import { removeSync, ensureDirSync, copySync } from 'fs-extra';
import { removeSync, ensureDirSync, copySync, readdirSync } from 'fs-extra';
import { join, resolve, sep } from 'path';
import { DefaultTasksRunnerOptions } from './default-tasks-runner';
import { spawn } from 'child_process';
Expand Down Expand Up @@ -190,11 +190,21 @@ export class Cache {
cachedResult: CachedResult,
outputs: string[]
): boolean {
return outputs.some(
(output) =>
existsSync(join(cachedResult.outputsPath, output)) &&
!existsSync(join(this.root, output))
);
return outputs.some((output) => {
const cacheOutputPath = join(cachedResult.outputsPath, output);
const rootOutputPath = join(this.root, output);

const haveDifferentAmountOfFiles =
existsSync(cacheOutputPath) &&
existsSync(rootOutputPath) &&
readdirSync(cacheOutputPath).length !==
readdirSync(rootOutputPath).length;

return (
(existsSync(cacheOutputPath) && !existsSync(rootOutputPath)) ||
haveDifferentAmountOfFiles
);
});
}

private getFileNameWithLatestRecordedHashForOutput(output: string): string {
Expand Down

0 comments on commit dc4270d

Please sign in to comment.