Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING(fs): remove Deno.fdatasync[Sync]() #25520

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/tools/test/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ 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` or `Deno.FsFile.syncData` call"],
"op_fs_file_sync_data_async" => ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.FsFile.prototype.syncData` call"],
"op_fs_file_stat_async" => ["get file metadata", "awaiting the result of a `Deno.FsFile.prototype.stat` call"],
"op_fs_flock_async" => ["lock a file", "awaiting the result of a `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"],
Expand Down
34 changes: 0 additions & 34 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1958,40 +1958,6 @@ declare namespace Deno {
*/
export function fsyncSync(rid: number): void;

/**
* Flushes any pending data operations of the given file stream to disk.
* ```ts
* const file = await Deno.open(
* "my_file.txt",
* { read: true, write: true, create: true },
* );
* await file.write(new TextEncoder().encode("Hello World"));
* await Deno.fdatasync(file.rid);
* console.log(await Deno.readTextFile("my_file.txt")); // Hello World
* ```
*
* @category File System
*/
export function fdatasync(rid: number): Promise<void>;

/**
* Synchronously flushes any pending data operations of the given file stream
* to disk.
*
* ```ts
* const file = Deno.openSync(
* "my_file.txt",
* { read: true, write: true, create: true },
* );
* file.writeSync(new TextEncoder().encode("Hello World"));
* Deno.fdatasyncSync(file.rid);
* console.log(Deno.readTextFileSync("my_file.txt")); // Hello World
* ```
*
* @category File System
*/
export function fdatasyncSync(rid: number): void;

/** The Deno abstraction for reading and writing files.
*
* This is the most straight forward way of handling files within Deno and is
Expand Down
18 changes: 4 additions & 14 deletions ext/fs/30_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
op_fs_copy_file_async,
op_fs_copy_file_sync,
op_fs_cwd,
op_fs_fdatasync_async,
op_fs_fdatasync_sync,
op_fs_file_stat_async,
op_fs_file_stat_sync,
op_fs_file_sync_data_async,
op_fs_file_sync_data_sync,
op_fs_file_truncate_async,
op_fs_flock_async,
op_fs_flock_sync,
Expand Down Expand Up @@ -517,14 +517,6 @@ async function symlink(
);
}

function fdatasyncSync(rid) {
op_fs_fdatasync_sync(rid);
}

async function fdatasync(rid) {
await op_fs_fdatasync_async(rid);
}

function fsyncSync(rid) {
op_fs_fsync_sync(rid);
}
Expand Down Expand Up @@ -648,11 +640,11 @@ class FsFile {
}

async syncData() {
await op_fs_fdatasync_async(this.#rid);
await op_fs_file_sync_data_async(this.#rid);
}

syncDataSync() {
op_fs_fdatasync_sync(this.#rid);
op_fs_file_sync_data_sync(this.#rid);
}

close() {
Expand Down Expand Up @@ -914,8 +906,6 @@ export {
create,
createSync,
cwd,
fdatasync,
fdatasyncSync,
FsFile,
fsync,
fsyncSync,
Expand Down
4 changes: 2 additions & 2 deletions ext/fs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ deno_core::extension!(deno_fs,

op_fs_seek_sync,
op_fs_seek_async,
op_fs_fdatasync_sync,
op_fs_fdatasync_async,
op_fs_file_sync_data_sync,
op_fs_file_sync_data_async,
op_fs_fsync_sync,
op_fs_fsync_async,
op_fs_file_stat_sync,
Expand Down
4 changes: 2 additions & 2 deletions ext/fs/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ pub async fn op_fs_seek_async(
}

#[op2(fast)]
pub fn op_fs_fdatasync_sync(
pub fn op_fs_file_sync_data_sync(
state: &mut OpState,
#[smi] rid: ResourceId,
) -> Result<(), AnyError> {
Expand All @@ -1440,7 +1440,7 @@ pub fn op_fs_fdatasync_sync(
}

#[op2(async)]
pub async fn op_fs_fdatasync_async(
pub async fn op_fs_file_sync_data_async(
state: Rc<RefCell<OpState>>,
#[smi] rid: ResourceId,
) -> Result<(), AnyError> {
Expand Down
2 changes: 0 additions & 2 deletions runtime/js/90_deno_ns.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ const denoNs = {
startTls: tls.startTls,
fsyncSync: fs.fsyncSync,
fsync: fs.fsync,
fdatasyncSync: fs.fdatasyncSync,
fdatasync: fs.fdatasync,
symlink: fs.symlink,
symlinkSync: fs.symlinkSync,
link: fs.link,
Expand Down
33 changes: 0 additions & 33 deletions tests/unit/sync_test.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals, DENO_FUTURE } from "./test_util.ts";

Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
function fdatasyncSyncSuccess() {
const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt";
using file = Deno.openSync(filename, {
read: true,
write: true,
create: true,
});
const data = new Uint8Array(64);
file.writeSync(data);
Deno.fdatasyncSync(file.rid);
Deno.removeSync(filename);
},
);

Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
async function fdatasyncSuccess() {
const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt";
using file = await Deno.open(filename, {
read: true,
write: true,
create: true,
});
const data = new Uint8Array(64);
await file.write(data);
await Deno.fdatasync(file.rid);
assertEquals(await Deno.readFile(filename), data);
await Deno.remove(filename);
},
);

Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
function fsyncSyncSuccess() {
Expand Down