| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 138c702 commit cf85d54
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1154,6 +1154,9 @@ async function utimes(path, atime, mtime) { | |||
| 1154 | 1154 | } | |
| 1155 | 1155 | ||
| 1156 | 1156 | async function futimes(handle, atime, mtime) { | |
| 1157 | + if (permission.isEnabled()) { | ||
| 1158 | + throw new ERR_ACCESS_DENIED('futimes API is disabled when Permission Model is enabled.'); | ||
| 1159 | + } | ||
| 1157 | 1160 | atime = toUnixTimestamp(atime, 'atime'); | |
| 1158 | 1161 | mtime = toUnixTimestamp(mtime, 'mtime'); | |
| 1159 | 1162 | return await PromisePrototypeThen( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + // Flags: --permission --allow-fs-read=* | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + const common = require('../common'); | ||
| 5 | + const { isMainThread } = require('worker_threads'); | ||
| 6 | + | ||
| 7 | + if (!isMainThread) { | ||
| 8 | + common.skip('This test only works on a main thread'); | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + if (!common.hasCrypto) { | ||
| 12 | + common.skip('no crypto'); | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + const assert = require('assert'); | ||
| 16 | + const { open } = require('fs/promises'); | ||
| 17 | + const fixtures = require('../common/fixtures'); | ||
| 18 | + | ||
| 19 | + const regularFile = fixtures.path('permission', 'deny', 'regular-file.md'); | ||
| 20 | + | ||
| 21 | + // FileHandle.utimes() must be blocked when the permission model is enabled, | ||
| 22 | + // consistent with fs.futimes() / fs.futimesSync(). | ||
| 23 | + (async () => { | ||
| 24 | + const fh = await open(regularFile, 'r'); | ||
| 25 | + try { | ||
| 26 | + await assert.rejects( | ||
| 27 | + fh.utimes(Date.now(), Date.now()), | ||
| 28 | + common.expectsError({ code: 'ERR_ACCESS_DENIED' }), | ||
| 29 | + ); | ||
| 30 | + } finally { | ||
| 31 | + await fh.close(); | ||
| 32 | + } | ||
| 33 | + })().then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments