From 6c167c64d61ecfc912dc1b68d300f02aa3677235 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Thu, 23 May 2024 07:59:51 +1000 Subject: [PATCH] feat(ext/fs): stabilize `Deno.FsFile.syncData[Sync]()` and `Deno.FsFile.sync[Sync]()` (#23733) Closes #22230 --- cli/tools/test/fmt.rs | 4 +--- cli/tsc/dts/lib.deno.ns.d.ts | 12 ++++------ ext/fs/30_fs.js | 12 ++++------ ext/fs/lib.rs | 4 ---- ext/fs/ops.rs | 44 ------------------------------------ 5 files changed, 9 insertions(+), 67 deletions(-) diff --git a/cli/tools/test/fmt.rs b/cli/tools/test/fmt.rs index d26d083b4a..966b488b17 100644 --- a/cli/tools/test/fmt.rs +++ b/cli/tools/test/fmt.rs @@ -308,12 +308,10 @@ pub const OP_DETAILS: phf::Map<&'static str, [&'static str; 2]> = phf_map! { "op_fs_chown_async" => ["change the owner of a file", "awaiting the result of a `Deno.chown` call"], "op_fs_copy_file_async" => ["copy a file", "awaiting the result of a `Deno.copyFile` call"], "op_fs_events_poll" => ["get the next file system event", "breaking out of a for await loop looping over `Deno.FsEvents`"], - "op_fs_fdatasync_async" => ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.fdatasync` call"], - "op_fs_fdatasync_async_unstable" => ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.FsFile.syncData` call"], + "op_fs_fdatasync_async" => ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.fdatasync` or `Deno.FsFile.syncData` call"], "op_fs_file_stat_async" => ["get file metadata", "awaiting the result of a `Deno.fstat` or `Deno.FsFile.stat` call"], "op_fs_flock_async" => ["lock a file", "awaiting the result of a `Deno.flock` or `Deno.FsFile.lock` call"], "op_fs_fsync_async" => ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.fsync` or `Deno.FsFile.sync` call"], - "op_fs_fsync_async_unstable" => ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.FsFile.sync` call"], "op_fs_ftruncate_async" => ["truncate a file", "awaiting the result of a `Deno.ftruncate` or `Deno.FsFile.truncate` call"], "op_fs_funlock_async" => ["unlock a file", "awaiting the result of a `Deno.funlock` or `Deno.FsFile.unlock` call"], "op_fs_futime_async" => ["change file timestamps", "awaiting the result of a `Deno.futime` or `Deno.FsFile.utime` call"], diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 09c669c282..c6b9df222c 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -2563,8 +2563,7 @@ declare namespace Deno { * ``` */ statSync(): FileInfo; - /** **UNSTABLE**: New API, yet to be vetted. - * + /** * Flushes any pending data and metadata operations of the given file * stream to disk. * @@ -2582,8 +2581,7 @@ declare namespace Deno { * @category I/O */ sync(): Promise; - /** **UNSTABLE**: New API, yet to be vetted. - * + /** * Synchronously flushes any pending data and metadata operations of the given * file stream to disk. * @@ -2601,8 +2599,7 @@ declare namespace Deno { * @category I/O */ syncSync(): void; - /** **UNSTABLE**: New API, yet to be vetted. - * + /** * Flushes any pending data operations of the given file stream to disk. * ```ts * using file = await Deno.open( @@ -2617,8 +2614,7 @@ declare namespace Deno { * @category I/O */ syncData(): Promise; - /** **UNSTABLE**: New API, yet to be vetted. - * + /** * Synchronously flushes any pending data operations of the given file stream * to disk. * diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index b6cd2d1f13..f0078392a5 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -16,17 +16,13 @@ import { op_fs_copy_file_sync, op_fs_cwd, op_fs_fdatasync_async, - op_fs_fdatasync_async_unstable, op_fs_fdatasync_sync, - op_fs_fdatasync_sync_unstable, op_fs_file_stat_async, op_fs_file_stat_sync, op_fs_flock_async, op_fs_flock_sync, op_fs_fsync_async, - op_fs_fsync_async_unstable, op_fs_fsync_sync, - op_fs_fsync_sync_unstable, op_fs_ftruncate_async, op_fs_ftruncate_sync, op_fs_funlock_async, @@ -732,11 +728,11 @@ class FsFile { } async syncData() { - await op_fs_fdatasync_async_unstable(this.#rid); + await op_fs_fdatasync_async(this.#rid); } syncDataSync() { - op_fs_fdatasync_sync_unstable(this.#rid); + op_fs_fdatasync_sync(this.#rid); } close() { @@ -758,11 +754,11 @@ class FsFile { } async sync() { - await op_fs_fsync_async_unstable(this.#rid); + await op_fs_fsync_async(this.#rid); } syncSync() { - op_fs_fsync_sync_unstable(this.#rid); + op_fs_fsync_sync(this.#rid); } async utime(atime, mtime) { diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs index d4e79b75f7..0c3b99c24d 100644 --- a/ext/fs/lib.rs +++ b/ext/fs/lib.rs @@ -144,12 +144,8 @@ deno_core::extension!(deno_fs, op_fs_seek_async, op_fs_fdatasync_sync, op_fs_fdatasync_async, - op_fs_fdatasync_sync_unstable, - op_fs_fdatasync_async_unstable, op_fs_fsync_sync, op_fs_fsync_async, - op_fs_fsync_sync_unstable, - op_fs_fsync_async_unstable, op_fs_file_stat_sync, op_fs_file_stat_async, op_fs_flock_sync, diff --git a/ext/fs/ops.rs b/ext/fs/ops.rs index 3ff32bd8f2..71edc7d116 100644 --- a/ext/fs/ops.rs +++ b/ext/fs/ops.rs @@ -1443,17 +1443,6 @@ pub fn op_fs_fdatasync_sync( Ok(()) } -#[op2(fast)] -pub fn op_fs_fdatasync_sync_unstable( - state: &mut OpState, - #[smi] rid: ResourceId, -) -> Result<(), AnyError> { - check_unstable(state, "Deno.FsFile.syncDataSync"); - let file = FileResource::get_file(state, rid)?; - file.datasync_sync()?; - Ok(()) -} - #[op2(async)] pub async fn op_fs_fdatasync_async( state: Rc>, @@ -1464,17 +1453,6 @@ pub async fn op_fs_fdatasync_async( Ok(()) } -#[op2(async)] -pub async fn op_fs_fdatasync_async_unstable( - state: Rc>, - #[smi] rid: ResourceId, -) -> Result<(), AnyError> { - check_unstable(&state.borrow(), "Deno.FsFile.syncData"); - let file = FileResource::get_file(&state.borrow(), rid)?; - file.datasync_async().await?; - Ok(()) -} - #[op2(fast)] pub fn op_fs_fsync_sync( state: &mut OpState, @@ -1485,17 +1463,6 @@ pub fn op_fs_fsync_sync( Ok(()) } -#[op2(fast)] -pub fn op_fs_fsync_sync_unstable( - state: &mut OpState, - #[smi] rid: ResourceId, -) -> Result<(), AnyError> { - check_unstable(state, "Deno.FsFile.syncSync"); - let file = FileResource::get_file(state, rid)?; - file.sync_sync()?; - Ok(()) -} - #[op2(async)] pub async fn op_fs_fsync_async( state: Rc>, @@ -1506,17 +1473,6 @@ pub async fn op_fs_fsync_async( Ok(()) } -#[op2(async)] -pub async fn op_fs_fsync_async_unstable( - state: Rc>, - #[smi] rid: ResourceId, -) -> Result<(), AnyError> { - check_unstable(&state.borrow(), "Deno.FsFile.sync"); - let file = FileResource::get_file(&state.borrow(), rid)?; - file.sync_async().await?; - Ok(()) -} - #[op2(fast)] pub fn op_fs_file_stat_sync( state: &mut OpState,