Bartek Iwańczuk
4a1f63b930
Revert "fix(ext/node): fs.stat
and fs.statSync
compatibility (#30… ( #30741 )
...
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
…637)"
This reverts commit 432761aac5
.
The tests are causing flakes on Windows
2025-09-15 19:25:47 -04:00
Daniel Osvaldo Rahmanto
432761aac5
fix(ext/node): fs.stat
and fs.statSync
compatibility ( #30637 )
...
ci / build libs (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Closes #30570
Changes in this PR:
- Implement `ino`, `nlink`, and `blocks` properties of `Deno.FileInfo`
on Windows. These changes are automatically reflected to the
corresponding node stat function. In order to do so, I had to tinker
with the
[createByteStruct](a3a904da14/ext/fs/30_fs.js (L297)
)
function to create another optional int type, apart from `?u64`. It's
common for small sized files on Windows (particularly NTFS file system)
to have a `Stats.blocks` property of 0, and currently all 0 values with
type `?u64` will be coerced into `null` by `createByteStruct`.
- Refactor the `BigIntStats` and `Stats` class, to use the same class
with Node.js that are provided from
[utils.mjs](7f8e488c36/ext/node/polyfills/internal/fs/utils.mjs (L577)
).
Also ensures that all properties are not `null` or `undefined`.
- Addresses the `prefer-primordials` lint rule.
2025-09-15 15:29:30 +02:00
Daniel Osvaldo R
e4a47febcd
fix(std/fs): implement chmod
on windows ( #30436 )
...
Closes #4357
On Windows, `chmod` can only change read and write permissions
(https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/chmod-wchmod?view=msvc-170 ).
It doesn't implement distinct permissions among group, owner, or others.
Changes in this PR also enables `node:fs`’ `chmod` on Windows and fixes
the `prefer-primordials` lint rule #24236 .
2025-08-18 19:06:22 +02:00
林炳权
68297b5f10
chore: Rust 1.89.0 ( #30364 )
...
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Related PR: https://github.com/denoland/deno/pull/30354
2025-08-09 11:11:48 +00:00
Daniel Osvaldo R
8680d97b38
fix(ext/node): fs.open
and fs.openSync
compatibility ( #30191 )
...
ci / build libs (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
Notable changes:
- Introduces a separate op between `Deno.open` and `node:fs.open`.
- Removes redundant `existenceCheckRequired` and `Deno.lstatSync` calls,
as the op layer already handles that when `options.create_new` is true
and uses synchronous I/O when `O_SYNC` is passed.
- Allows passing custom flags to the op (e.g. `O_SYNC`).
- Addresses `prefer-primordials` lint rule.
- Allows
[parallel/test-fs-open.js](https://github.com/nodejs/node/blob/v23.9.0/test/parallel/test-fs-open.js )
test to pass. There are also several tests that have passed before that
I added to the config.toml.
2025-07-31 15:10:10 +00:00
David Sherret
7e6c827858
refactor: remove some allocations in op_require_x ops ( #30212 )
2025-07-28 15:44:21 +00:00
David Sherret
76ce7768ab
refactor(permissions): remove access check callback ( #30050 )
...
1. Removes the access check callback, which was kind of confusing.
1. Requires `CheckedPath` for everything in the `FileSystem` trait to
ensure we're always checking permissions.
2025-07-10 21:40:20 -04:00
David Sherret
2617b4ec6b
refactor(permissions): push down special file checking to permissions container ( #30005 )
2025-07-09 20:50:26 +00:00
Nathan Whitaker
9379a74e08
chore: update to edition 2024 ( #29923 )
ci / publish canary (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
2025-07-02 17:59:39 -07:00
Daniel Osvaldo R
0f0220e461
fix(ext/node): add fchmod
and fchmodSync
( #29791 )
...
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
This PR implements `node:fs` `fchmod` and `fchmodSync`.
Towards https://github.com/denoland/deno/issues/27664 .
2025-06-18 12:48:14 +02:00
Yoshiya Hinosawa
3de21f1b8d
fix(ext/node): add fchown
and fchownSync
to node:fs
( #29408 )
ci / pre-build (push) Has been cancelled
ci / test debug macos-x86_64 (push) Has been cancelled
ci / test release macos-x86_64 (push) Has been cancelled
ci / test debug windows-x86_64 (push) Has been cancelled
ci / test release windows-x86_64 (push) Has been cancelled
ci / test debug linux-aarch64 (push) Has been cancelled
ci / test release linux-aarch64 (push) Has been cancelled
ci / test debug macos-aarch64 (push) Has been cancelled
ci / test release macos-aarch64 (push) Has been cancelled
ci / bench release linux-x86_64 (push) Has been cancelled
ci / lint debug linux-x86_64 (push) Has been cancelled
ci / lint debug macos-x86_64 (push) Has been cancelled
ci / lint debug windows-x86_64 (push) Has been cancelled
ci / test debug linux-x86_64 (push) Has been cancelled
ci / test release linux-x86_64 (push) Has been cancelled
ci / build wasm32 (push) Has been cancelled
ci / publish canary (push) Has been cancelled
2025-05-23 15:00:39 +09:00
Nathan Whitaker
c22d17824b
perf(fs): don't canonicalize path when opening file if --allow-all
is passed ( #28716 )
...
Fixes #28702 .
Super artificial benchmark:
```ts
const perf = performance;
async function asyncOpen() {
const start = perf.now();
for (let i = 0; i < 100_000; i++) {
const file = await Deno.open("./foo.txt");
file.close();
}
const end = perf.now();
console.log(end - start);
}
function syncOpen() {
const start = perf.now();
for (let i = 0; i < 100_000; i++) {
const file = Deno.openSync("./foo.txt");
file.close();
}
const end = perf.now();
console.log(end - start);
}
if (Deno.args[0]?.trim() === "async") {
await asyncOpen();
} else {
syncOpen();
}
```
Results (average of 10 for each):
```
deno sync 1785.59
deno-this-pr sync 491.69
deno async 1839.71
deno-this-pr async 528.78
```
---------
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2025-04-29 23:16:24 +00:00
Marvin Hagemeister
4e655e543f
feat: Deno.cwd() no longer requires --allow-read permission ( #27192 )
...
This commit changes "Deno.cwd()" (as well as "process.cwd()") to no
longer require full "--allow-read" permission. This change was meant to be done
in Deno 2.0.0, but somehow it slipped. Requiring full read permission
just to read the CWD is a mistake, because CWD can already be obtained
with no permission by throwing an error in JS and inspecting its stack.
Fixes https://github.com/denoland/deno/issues/27110
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-27 15:13:59 +01:00
Leo Kettmeir
ea30e188a8
refactor: update deno_core for error refactor ( #26867 )
...
Closes #26171
---------
Co-authored-by: David Sherret <dsherret@gmail.com>
2025-01-08 14:52:32 -08:00
Kenta Moriuchi
8fb073d7b4
chore: Happy New Year 2025 ( #27509 )
2024-12-31 19:12:39 +00:00
David Sherret
ac7b33a340
chore: cargo fmt - turn on group_imports=StdExternalCrate ( #26646 )
2024-12-31 12:13:39 -05:00
David Sherret
4638caa740
refactor: do not use deno_fs::FileSystem
everywhere ( #27508 )
...
This changes the cli to mostly use `std::fs` via `sys_traits` instead of
the implemention of `deno_fs::FileSystem`.
2024-12-31 11:29:07 -05:00
Divy Srivastava
50871b2aa3
fix: FastString v8_string() should error when cannot allocated ( #27375 )
...
Upgrades deno_core to 0.326.0
2024-12-16 13:51:49 +00:00
David Sherret
f161adf19e
perf(compile): read embedded files as static references when UTF-8 and reading as strings ( #27033 )
2024-11-27 21:28:41 -05:00
Leo Kettmeir
cf49599359
feat: permission stack traces in ops ( #26938 )
...
This commit improves permission prompts by adding an option
to print a full trace of where the permissions is being requested.
Due to big performance hint of stack trace collection, this is only
enabled when `DENO_TRACE_PERMISSIONS` env var is present.
Closes https://github.com/denoland/deno/issues/20756
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-11-20 21:24:04 +00:00
David Sherret
48b94c0995
refactor: use boxed_error in some places ( #26887 )
2024-11-15 23:22:50 -05:00
Łukasz Czerniawski
7becd83a38
feat(ext/fs): add ctime to Deno.stats and use it in node compat layer ( #24801 )
...
This PR fixes #24453 , by introducing a ctime (using ctime for UNIX and
ChangeTime for Windows) to Deno.stats.
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2024-11-13 13:35:04 +09:00
Leo Kettmeir
fe9f0ee593
refactor(runtime/permissions): use concrete error types ( #26464 )
2024-11-04 09:17:21 -08:00
Leo Kettmeir
85a99eb405
refactor(ext/fs): use concrete error types ( #26317 )
2024-10-18 06:38:17 -07:00
David Sherret
1bb47805d6
refactor: move NpmCacheDir to deno_cache_dir ( #25916 )
...
Part of the ongoing work to move more of Deno's resolution out of the
CLI crate (for use in Wasm and other things)
Includes:
* https://github.com/denoland/deno_cache_dir/pull/60
2024-09-28 08:50:16 -04:00
David Sherret
62e952559f
refactor(permissions): split up Descriptor into Allow, Deny, and Query ( #25508 )
...
This makes the permission system more versatile.
2024-09-16 21:39:37 +01:00
Asher Gomez
9e8f84214f
refactor: cleanup unstable checks for WebGPU, FFI and FS APIs ( #25586 )
...
Continuation of work in #25488 .
---------
Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-09-12 12:27:16 +00:00
Luca Casonato
7bfcb4dd10
feat(cli): use NotCapable error for permission errors ( #25431 )
...
Closes #7394
---------
Co-authored-by: snek <snek@deno.com>
2024-09-10 11:12:24 -07:00
Asher Gomez
a445ebd74f
BREAKING(fs): remove Deno.fsync[Sync]()
( #25448 )
...
Towards #22079
---------
Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-09-09 22:39:56 +00:00
Asher Gomez
39f2704bd7
BREAKING(fs): remove Deno.fdatasync[Sync]()
( #25520 )
2024-09-09 21:09:57 +10:00
Asher Gomez
7d95c5c062
BREAKING(fs): remove Deno.funlock[Sync]()
( #25442 )
...
Towards #22079
---------
Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-09-05 11:23:37 +00:00
Asher Gomez
3d36cbd056
BREAKING(fs): remove Deno.ftruncate[Sync]()
( #25412 )
...
Towards #22079
Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-09-04 08:53:43 +00:00
Asher Gomez
9bf10aa1e0
chore(fs): remove Deno.flock[Sync]()
( #25350 )
...
Towards #22079
2024-09-03 18:39:37 +10:00
Yazan AbdAl-Rahman
4f49f703c1
fix(cli): update permission prompt message for compiled binaries ( #24081 )
...
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-08-20 01:20:06 +00:00
Luca Casonato
c1f23c5788
fix(ext/node): lossy UTF-8 read node_modules files ( #24140 )
...
Previously various reads of files in `node_modules` would error on
invalid UTF-8. These were cases involving:
- reading package.json from Rust
- reading package.json from JS
- reading CommonJS files from JS
- reading CommonJS files from Rust (for ESM translation)
- reading ESM files from Rust
2024-06-08 18:36:13 +02:00
Asher Gomez
4908d45758
feat(ext/fs): stabilize Deno.FsFile.unlock[Sync]()
and Deno.FsFile.lock[Sync]()
( #23754 )
...
Related #22230
CC @dyedgreen
2024-05-23 09:17:00 +10:00
Asher Gomez
6c167c64d6
feat(ext/fs): stabilize Deno.FsFile.syncData[Sync]()
and Deno.FsFile.sync[Sync]()
( #23733 )
...
Closes #22230
2024-05-22 21:59:51 +00:00
Matt Mastracci
472a370640
feat(runtime): Allow embedders to perform additional access checks on file open ( #23208 )
...
Embedders may have special requirements around file opening, so we add a
new `check_open` permission check that is called as part of the file
open process.
2024-04-19 18:12:03 -06:00
Matt Mastracci
76ebf567e2
fix(ext/fs): make errors in tempfile creation clearer ( #22498 )
...
When using a prefix or suffix containing an invalid filename character,
it's not entirely clear where the errors come from. We make these errors
more consistent across platforms.
In addition, all permission prompts for tempfile and tempdir were
printing the same API name.
We also take the opportunity to make the tempfile random space larger by
2x (using a base32-encoded u64 rather than a hex-encoded u32).
2024-02-21 20:11:04 +00:00
Asher Gomez
eb542bc185
chore(fs): rename op_fs_file_stat_{async/sync}
ops ( #22476 )
...
Renames `op_fs_fstat_{sync/async}` to `op_fs_file_stat_{async/sync}` in
preparation of the upcoming removal of `Deno.fstat()` in v2.
2024-02-19 06:33:42 -07:00
Bartek Iwańczuk
801ed74118
revert: Remove deprecations of file sync APIs ( #22085 )
...
- `Deno.FsFile.dataSync` -> `Deno.FsFile.syncData`
- `Deno.FsFile.dataSyncSync` -> `Deno.FsFile.syncDataSync`
Also marks these APIs as unstable
2024-01-24 23:38:18 +01:00
David Sherret
7e72f3af61
chore: update copyright to 2024 ( #21753 )
2024-01-01 19:58:21 +00:00
Bartek Iwańczuk
a5568066b3
refactor: use deno_core::FeatureChecker for unstable checks ( #20765 )
2023-10-04 21:42:17 +02:00
Bartek Iwańczuk
b2abae4771
refactor: rewrite more ops to op2 ( #20666 )
2023-09-24 22:07:22 +00:00
Bartek Iwańczuk
68851d6f37
refactor: rewrite ops to op2 macro ( #20628 )
...
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-09-23 19:33:31 +00:00
Matt Mastracci
81d50e1b66
chore: bump deno_core and cargo update ( #20480 )
...
Bump deno_core, pulling in new rusty_v8. Requires some op2/deprecation
fixes.
2023-09-13 22:01:31 +00:00
Matt Mastracci
29784df24e
chore(ext/fs): port some ops to op2 ( #20402 )
...
Port as many of these ops as we can to `op2`. Waiting on a few
`deno_core` updates to complete this file.
2023-09-07 13:19:20 -06:00
Asher Gomez
6fb7e8d93b
feat(permissions): add "--deny-*" flags ( #19070 )
...
This commit adds new "--deny-*" permission flags. These are complimentary to
"--allow-*" flags.
These flags can be used to restrict access to certain resources, even if they
were granted using "--allow-*" flags or the "--allow-all" ("-A") flag.
Eg. specifying "--allow-read --deny-read" will result in a permission error,
while "--allow-read --deny-read=/etc" will allow read access to all FS but the
"/etc" directory.
Runtime permissions APIs ("Deno.permissions") were adjusted as well, mainly
by adding, a new "PermissionStatus.partial" field. This field denotes that
while permission might be granted to requested resource, it's only partial (ie.
a "--deny-*" flag was specified that excludes some of the requested resources).
Eg. specifying "--allow-read=foo/ --deny-read=foo/bar" and then querying for
permissions like "Deno.permissions.query({ name: "read", path: "foo/" })"
will return "PermissionStatus { state: "granted", onchange: null, partial: true }",
denoting that some of the subpaths don't have read access.
Closes #18804 .
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2023-08-03 13:19:19 +02:00
Bartek Iwańczuk
dda0f1c343
refactor(serde_v8): split ZeroCopyBuf into JsBuffer and ToJsBuffer ( #19566 )
...
`ZeroCopyBuf` was convenient to use, but sometimes it did hide details
that some copies were necessary in certain cases. Also it made it way to easy
for the caller to pass around and convert into different values. This commit
splits `ZeroCopyBuf` into `JsBuffer` (an array buffer coming from V8) and
`ToJsBuffer` (a Rust buffer that will be converted into a V8 array buffer).
As a result some magical conversions were removed (they were never used)
limiting the API surface and preparing for changes in #19534 .
2023-06-22 23:37:56 +02:00
Hirotaka Tagawa / wafuwafu13
114ec3c1f7
feat(ext/fs): add isBlockDevice, isCharDevice, isFifo, isSocket to FileInfo ( #19008 )
...
`isFile`, `isDirectory`, `isSymlink` are defined in `Deno.FileInfo`, but
`isBlockDevice`, `isCharacterDevice`, `isFIFO`, `isSocket` are not
defined.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-24 21:18:13 +02:00