Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
5c38caab
Unverified
Commit
5c38caab
authored
Aug 05, 2025
by
xusd320
Committed by
GitHub
Aug 05, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(turbo-tasks-fs): change FS to_sys_path to be synchronous (#82341)
parent
d6337894
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
17 deletions
+14
-17
project.rs
crates/napi/src/next_api/project.rs
+1
-1
lib.rs
turbopack/crates/turbo-tasks-fs/src/lib.rs
+8
-8
util.rs
turbopack/crates/turbo-tasks-fs/src/util.rs
+5
-8
No files found.
crates/napi/src/next_api/project.rs
View file @
5c38caab
...
@@ -541,7 +541,7 @@ async fn benchmark_file_io(
...
@@ -541,7 +541,7 @@ async fn benchmark_file_io(
))
?
))
?
.await
?
;
.await
?
;
let
directory
=
fs
.to_sys_path
(
directory
)
.await
?
;
let
directory
=
fs
.to_sys_path
(
directory
)
?
;
let
temp_path
=
directory
.join
(
format!
(
let
temp_path
=
directory
.join
(
format!
(
"tmp_file_io_benchmark_{:x}"
,
"tmp_file_io_benchmark_{:x}"
,
rand
::
random
::
<
u128
>
()
rand
::
random
::
<
u128
>
()
...
...
turbopack/crates/turbo-tasks-fs/src/lib.rs
View file @
5c38caab
...
@@ -474,7 +474,7 @@ impl DiskFileSystem {
...
@@ -474,7 +474,7 @@ impl DiskFileSystem {
self
.inner.watcher
.stop_watching
();
self
.inner.watcher
.stop_watching
();
}
}
pub
async
fn
to_sys_path
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
PathBuf
>
{
pub
fn
to_sys_path
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
PathBuf
>
{
// just in case there's a windows unc path prefix we remove it with `dunce`
// just in case there's a windows unc path prefix we remove it with `dunce`
let
path
=
self
.inner
.root_path
();
let
path
=
self
.inner
.root_path
();
Ok
(
if
fs_path
.path
.is_empty
()
{
Ok
(
if
fs_path
.path
.is_empty
()
{
...
@@ -545,7 +545,7 @@ impl FileSystem for DiskFileSystem {
...
@@ -545,7 +545,7 @@ impl FileSystem for DiskFileSystem {
#[turbo_tasks
::
function(fs)]
#[turbo_tasks
::
function(fs)]
async
fn
read
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
Vc
<
FileContent
>>
{
async
fn
read
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
Vc
<
FileContent
>>
{
mark_session_dependent
();
mark_session_dependent
();
let
full_path
=
self
.to_sys_path
(
fs_path
)
.await
?
;
let
full_path
=
self
.to_sys_path
(
fs_path
)
?
;
self
.inner
.register_read_invalidator
(
&
full_path
)
?
;
self
.inner
.register_read_invalidator
(
&
full_path
)
?
;
let
_lock
=
self
.inner
.lock_path
(
&
full_path
)
.await
;
let
_lock
=
self
.inner
.lock_path
(
&
full_path
)
.await
;
...
@@ -571,7 +571,7 @@ impl FileSystem for DiskFileSystem {
...
@@ -571,7 +571,7 @@ impl FileSystem for DiskFileSystem {
#[turbo_tasks
::
function(fs)]
#[turbo_tasks
::
function(fs)]
async
fn
raw_read_dir
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
Vc
<
RawDirectoryContent
>>
{
async
fn
raw_read_dir
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
Vc
<
RawDirectoryContent
>>
{
mark_session_dependent
();
mark_session_dependent
();
let
full_path
=
self
.to_sys_path
(
fs_path
)
.await
?
;
let
full_path
=
self
.to_sys_path
(
fs_path
)
?
;
self
.inner
.register_dir_invalidator
(
&
full_path
)
?
;
self
.inner
.register_dir_invalidator
(
&
full_path
)
?
;
// we use the sync std function here as it's a lot faster (600%) in
// we use the sync std function here as it's a lot faster (600%) in
...
@@ -626,7 +626,7 @@ impl FileSystem for DiskFileSystem {
...
@@ -626,7 +626,7 @@ impl FileSystem for DiskFileSystem {
#[turbo_tasks
::
function(fs)]
#[turbo_tasks
::
function(fs)]
async
fn
read_link
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
Vc
<
LinkContent
>>
{
async
fn
read_link
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
Vc
<
LinkContent
>>
{
mark_session_dependent
();
mark_session_dependent
();
let
full_path
=
self
.to_sys_path
(
fs_path
.clone
())
.await
?
;
let
full_path
=
self
.to_sys_path
(
fs_path
.clone
())
?
;
self
.inner
.register_read_invalidator
(
&
full_path
)
?
;
self
.inner
.register_read_invalidator
(
&
full_path
)
?
;
let
_lock
=
self
.inner
.lock_path
(
&
full_path
)
.await
;
let
_lock
=
self
.inner
.lock_path
(
&
full_path
)
.await
;
...
@@ -716,7 +716,7 @@ impl FileSystem for DiskFileSystem {
...
@@ -716,7 +716,7 @@ impl FileSystem for DiskFileSystem {
// `write` purely declares a side effect and does not need to be reexecuted in the next
// `write` purely declares a side effect and does not need to be reexecuted in the next
// session. All side effects are reexecuted in general.
// session. All side effects are reexecuted in general.
let
full_path
=
self
.to_sys_path
(
fs_path
)
.await
?
;
let
full_path
=
self
.to_sys_path
(
fs_path
)
?
;
let
content
=
content
.await
?
;
let
content
=
content
.await
?
;
let
inner
=
self
.inner
.clone
();
let
inner
=
self
.inner
.clone
();
let
invalidator
=
turbo_tasks
::
get_invalidator
();
let
invalidator
=
turbo_tasks
::
get_invalidator
();
...
@@ -851,7 +851,7 @@ impl FileSystem for DiskFileSystem {
...
@@ -851,7 +851,7 @@ impl FileSystem for DiskFileSystem {
// `write_link` purely declares a side effect and does not need to be reexecuted in the next
// `write_link` purely declares a side effect and does not need to be reexecuted in the next
// session. All side effects are reexecuted in general.
// session. All side effects are reexecuted in general.
let
full_path
=
self
.to_sys_path
(
fs_path
)
.await
?
;
let
full_path
=
self
.to_sys_path
(
fs_path
)
?
;
let
content
=
target
.await
?
;
let
content
=
target
.await
?
;
let
inner
=
self
.inner
.clone
();
let
inner
=
self
.inner
.clone
();
let
invalidator
=
turbo_tasks
::
get_invalidator
();
let
invalidator
=
turbo_tasks
::
get_invalidator
();
...
@@ -975,7 +975,7 @@ impl FileSystem for DiskFileSystem {
...
@@ -975,7 +975,7 @@ impl FileSystem for DiskFileSystem {
#[turbo_tasks
::
function(fs)]
#[turbo_tasks
::
function(fs)]
async
fn
metadata
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
Vc
<
FileMeta
>>
{
async
fn
metadata
(
&
self
,
fs_path
:
FileSystemPath
)
->
Result
<
Vc
<
FileMeta
>>
{
mark_session_dependent
();
mark_session_dependent
();
let
full_path
=
self
.to_sys_path
(
fs_path
)
.await
?
;
let
full_path
=
self
.to_sys_path
(
fs_path
)
?
;
self
.inner
.register_read_invalidator
(
&
full_path
)
?
;
self
.inner
.register_read_invalidator
(
&
full_path
)
?
;
let
_lock
=
self
.inner
.lock_path
(
&
full_path
)
.await
;
let
_lock
=
self
.inner
.lock_path
(
&
full_path
)
.await
;
...
@@ -2308,7 +2308,7 @@ pub async fn to_sys_path(mut path: FileSystemPath) -> Result<Option<PathBuf>> {
...
@@ -2308,7 +2308,7 @@ pub async fn to_sys_path(mut path: FileSystemPath) -> Result<Option<PathBuf>> {
}
}
if
let
Some
(
fs
)
=
Vc
::
try_resolve_downcast_type
::
<
DiskFileSystem
>
(
path
.fs
())
.await
?
{
if
let
Some
(
fs
)
=
Vc
::
try_resolve_downcast_type
::
<
DiskFileSystem
>
(
path
.fs
())
.await
?
{
let
sys_path
=
fs
.await
?
.to_sys_path
(
path
)
.await
?
;
let
sys_path
=
fs
.await
?
.to_sys_path
(
path
)
?
;
return
Ok
(
Some
(
sys_path
));
return
Ok
(
Some
(
sys_path
));
}
}
...
...
turbopack/crates/turbo-tasks-fs/src/util.rs
View file @
5c38caab
...
@@ -152,8 +152,7 @@ pub async fn uri_from_file(root: FileSystemPath, path: Option<&str>) -> Result<S
...
@@ -152,8 +152,7 @@ pub async fn uri_from_file(root: FileSystemPath, path: Option<&str>) -> Result<S
.to_sys_path
(
match
path
{
.to_sys_path
(
match
path
{
Some
(
path
)
=>
root
.join
(
path
)
?
,
Some
(
path
)
=>
root
.join
(
path
)
?
,
None
=>
root
,
None
=>
root
,
})
})
?
.await
?
.to_string_lossy
()
.to_string_lossy
()
)
)
.split
(
'/'
)
.split
(
'/'
)
...
@@ -171,12 +170,10 @@ pub async fn uri_from_file(root: FileSystemPath, path: Option<&str>) -> Result<S
...
@@ -171,12 +170,10 @@ pub async fn uri_from_file(root: FileSystemPath, path: Option<&str>) -> Result<S
.context
(
"Expected root to have a DiskFileSystem"
)
?
.context
(
"Expected root to have a DiskFileSystem"
)
?
.await
?
;
.await
?
;
let
sys_path
=
root_fs
let
sys_path
=
root_fs
.to_sys_path
(
match
path
{
.to_sys_path
(
match
path
{
Some
(
path
)
=>
root
.join
(
path
.into
())
?
,
Some
(
path
)
=>
root
.join
(
path
.into
())
?
,
None
=>
root
,
None
=>
root
,
})
?
;
})
.await
?
;
let
raw_path
=
sys_path
.to_string_lossy
()
.to_string
();
let
raw_path
=
sys_path
.to_string_lossy
()
.to_string
();
let
normalized_path
=
raw_path
.replace
(
'\\'
,
"/"
);
let
normalized_path
=
raw_path
.replace
(
'\\'
,
"/"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment