diff --git a/packages/nx/src/native/cache/cache.rs b/packages/nx/src/native/cache/cache.rs index e300f76b2dac4..e1236b741e255 100644 --- a/packages/nx/src/native/cache/cache.rs +++ b/packages/nx/src/native/cache/cache.rs @@ -26,6 +26,7 @@ pub struct NxCache { workspace_root: PathBuf, cache_path: PathBuf, db: External, + link_task_details: bool, } #[napi] @@ -35,6 +36,7 @@ impl NxCache { workspace_root: String, cache_path: String, db_connection: External, + link_task_details: Option, ) -> anyhow::Result { let cache_path = PathBuf::from(&cache_path); @@ -46,6 +48,7 @@ impl NxCache { workspace_root: PathBuf::from(workspace_root), cache_directory: cache_path.to_normalized_string(), cache_path, + link_task_details: link_task_details.unwrap_or(true) }; r.setup()?; @@ -54,9 +57,8 @@ impl NxCache { } fn setup(&self) -> anyhow::Result<()> { - self.db - .execute_batch( - "BEGIN; + let query = if self.link_task_details { + "BEGIN; CREATE TABLE IF NOT EXISTS cache_outputs ( hash TEXT PRIMARY KEY NOT NULL, code INTEGER NOT NULL, @@ -64,8 +66,23 @@ impl NxCache { accessed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (hash) REFERENCES task_details (hash) ); - COMMIT; - ", + COMMIT; + " + } else { + "BEGIN; + CREATE TABLE IF NOT EXISTS cache_outputs ( + hash TEXT PRIMARY KEY NOT NULL, + code INTEGER NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + accessed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ); + COMMIT; + " + }; + + self.db + .execute_batch( + query, ) .map_err(anyhow::Error::from) } @@ -115,6 +132,7 @@ impl NxCache { outputs: Vec, code: i16, ) -> anyhow::Result<()> { + trace!("PUT {}", &hash); let task_dir = self.cache_path.join(&hash); // Remove the task directory diff --git a/packages/nx/src/native/index.d.ts b/packages/nx/src/native/index.d.ts index 2839c5a94ee05..0b378e8302835 100644 --- a/packages/nx/src/native/index.d.ts +++ b/packages/nx/src/native/index.d.ts @@ -28,7 +28,7 @@ export declare class ImportResult { export declare class NxCache { cacheDirectory: string - constructor(workspaceRoot: string, cachePath: string, dbConnection: ExternalObject) + constructor(workspaceRoot: string, cachePath: string, dbConnection: ExternalObject, linkTaskDetails?: boolean | undefined | null) get(hash: string): CachedResult | null put(hash: string, terminalOutput: string, outputs: Array, code: number): void applyRemoteCacheResults(hash: string, result: CachedResult): void