fix(core): drop file lock after its used (#20165)
This commit is contained in:
parent
d899abe7f4
commit
c04fa3ad5f
@ -8,9 +8,11 @@ import { verifyOrUpdateNxCloudClient } from '../src/nx-cloud/update-manager';
|
|||||||
import { getCloudOptions } from '../src/nx-cloud/utilities/get-cloud-options';
|
import { getCloudOptions } from '../src/nx-cloud/utilities/get-cloud-options';
|
||||||
import { isNxCloudUsed } from '../src/utils/nx-cloud-utils';
|
import { isNxCloudUsed } from '../src/utils/nx-cloud-utils';
|
||||||
import { readNxJson } from '../src/config/nx-json';
|
import { readNxJson } from '../src/config/nx-json';
|
||||||
|
import { setupWorkspaceContext } from '../src/utils/workspace-context';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
setupWorkspaceContext(workspaceRoot);
|
||||||
if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) {
|
if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) {
|
||||||
const b = new Date();
|
const b = new Date();
|
||||||
assertSupportedPlatform();
|
assertSupportedPlatform();
|
||||||
|
|||||||
@ -65,13 +65,14 @@ impl FilesWorker {
|
|||||||
FilesWorker(Some(files_lock))
|
FilesWorker(Some(files_lock))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_files(&self) -> Option<MutexGuard<'_, RawMutex, Files>> {
|
pub fn get_files(&self) -> Option<Vec<(PathBuf, String)>> {
|
||||||
let Some(files_sync) = &self.0 else {
|
let Some(files_sync) = &self.0 else {
|
||||||
trace!("there were no files because the workspace root did not exist");
|
trace!("there were no files because the workspace root did not exist");
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
let (files_lock, cvar) = &files_sync.deref();
|
let (files_lock, cvar) = &files_sync.deref();
|
||||||
|
trace!("locking files");
|
||||||
let mut files = files_lock.lock();
|
let mut files = files_lock.lock();
|
||||||
let files_len = files.len();
|
let files_len = files.len();
|
||||||
if files_len == 0 {
|
if files_len == 0 {
|
||||||
@ -79,8 +80,11 @@ impl FilesWorker {
|
|||||||
cvar.wait(&mut files);
|
cvar.wait(&mut files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cloned_files = files.clone();
|
||||||
|
drop(files);
|
||||||
|
|
||||||
trace!("files are available");
|
trace!("files are available");
|
||||||
Some(files)
|
Some(cloned_files)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_files(
|
pub fn update_files(
|
||||||
@ -156,22 +160,13 @@ impl WorkspaceContext {
|
|||||||
workspace_files::get_files(
|
workspace_files::get_files(
|
||||||
globs,
|
globs,
|
||||||
parse_configurations,
|
parse_configurations,
|
||||||
self.files_worker
|
self.files_worker.get_files().as_deref(),
|
||||||
.get_files()
|
|
||||||
.as_deref()
|
|
||||||
.map(|files| files.as_slice()),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn glob(&self, globs: Vec<String>) -> napi::Result<Vec<String>, WorkspaceErrors> {
|
pub fn glob(&self, globs: Vec<String>) -> napi::Result<Vec<String>, WorkspaceErrors> {
|
||||||
config_files::glob_files(
|
config_files::glob_files(globs, self.files_worker.get_files().as_deref())
|
||||||
globs,
|
|
||||||
self.files_worker
|
|
||||||
.get_files()
|
|
||||||
.as_deref()
|
|
||||||
.map(|files| files.as_slice()),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
@ -185,10 +180,7 @@ impl WorkspaceContext {
|
|||||||
{
|
{
|
||||||
config_files::get_project_configurations(
|
config_files::get_project_configurations(
|
||||||
globs,
|
globs,
|
||||||
self.files_worker
|
self.files_worker.get_files().as_deref(),
|
||||||
.get_files()
|
|
||||||
.as_deref()
|
|
||||||
.map(|files| files.as_slice()),
|
|
||||||
parse_configurations,
|
parse_configurations,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user