@zenfs/core 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import type { File } from '../file.js';
2
2
  import type { FileSystemMetadata } from '../filesystem.js';
3
3
  import { FileSystem } from '../filesystem.js';
4
- import { Stats } from '../stats.js';
4
+ import type { Stats } from '../stats.js';
5
5
  /**
6
6
  * Configuration options for OverlayFS instances.
7
7
  */
@@ -710,7 +710,7 @@ export async function link(targetPath, linkPath) {
710
710
  if (config.checkAccess && !(await stat(dirname(linkPath))).hasAccess(constants.W_OK)) {
711
711
  throw ErrnoError.With('EACCES', dirname(linkPath), 'link');
712
712
  }
713
- if (config.checkAccess && !(await fs.stat(path)).hasAccess(constants.W_OK | constants.R_OK)) {
713
+ if (config.checkAccess && !(await fs.stat(path)).hasAccess(constants.R_OK)) {
714
714
  throw ErrnoError.With('EACCES', path, 'link');
715
715
  }
716
716
  return await fs.link(path, link.path);
@@ -99,7 +99,9 @@ export function fixError(e, paths) {
99
99
  try {
100
100
  e.message = fixPaths(e.message, paths);
101
101
  }
102
- catch { }
102
+ catch {
103
+ // `message` is read only
104
+ }
103
105
  return e;
104
106
  }
105
107
  /**
@@ -510,7 +510,7 @@ export function linkSync(targetPath, linkPath) {
510
510
  throw ErrnoError.With('EXDEV', linkPath, 'link');
511
511
  }
512
512
  try {
513
- if (config.checkAccess && !fs.statSync(path).hasAccess(constants.W_OK)) {
513
+ if (config.checkAccess && !fs.statSync(path).hasAccess(constants.R_OK)) {
514
514
  throw ErrnoError.With('EACCES', path, 'link');
515
515
  }
516
516
  return fs.linkSync(path, linkPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -5,7 +5,7 @@ import { PreloadFile, parseFlag } from '../file.js';
5
5
  import type { FileSystemMetadata } from '../filesystem.js';
6
6
  import { FileSystem } from '../filesystem.js';
7
7
  import { Mutexed } from '../mixins/mutexed.js';
8
- import { Stats } from '../stats.js';
8
+ import type { Stats } from '../stats.js';
9
9
  import { decodeUTF8, encodeUTF8 } from '../utils.js';
10
10
  import type { Backend } from './backend.js';
11
11
  /** @internal */
@@ -471,7 +471,7 @@ export async function unlink(path: fs.PathLike): Promise<void> {
471
471
  path = normalizePath(path);
472
472
  const { fs, path: resolved } = resolveMount(path);
473
473
  try {
474
- if (config.checkAccess && !(await (cache.stats.get(path) || fs.stat(resolved)))!.hasAccess(constants.W_OK)) {
474
+ if (config.checkAccess && !(await (cache.stats.get(path) || fs.stat(resolved))).hasAccess(constants.W_OK)) {
475
475
  throw ErrnoError.With('EACCES', resolved, 'unlink');
476
476
  }
477
477
  await fs.unlink(resolved);
@@ -795,7 +795,7 @@ export async function link(targetPath: fs.PathLike, linkPath: fs.PathLike): Prom
795
795
  throw ErrnoError.With('EACCES', dirname(linkPath), 'link');
796
796
  }
797
797
 
798
- if (config.checkAccess && !(await fs.stat(path)).hasAccess(constants.W_OK | constants.R_OK)) {
798
+ if (config.checkAccess && !(await fs.stat(path)).hasAccess(constants.R_OK)) {
799
799
  throw ErrnoError.With('EACCES', path, 'link');
800
800
  }
801
801
  return await fs.link(path, link.path);
@@ -114,7 +114,9 @@ export function fixError<E extends ErrnoError>(e: E, paths: Record<string, strin
114
114
  }
115
115
  try {
116
116
  e.message = fixPaths(e.message, paths);
117
- } catch {}
117
+ } catch {
118
+ // `message` is read only
119
+ }
118
120
  return e;
119
121
  }
120
122
 
@@ -524,7 +524,7 @@ export function linkSync(targetPath: fs.PathLike, linkPath: fs.PathLike): void {
524
524
  throw ErrnoError.With('EXDEV', linkPath, 'link');
525
525
  }
526
526
  try {
527
- if (config.checkAccess && !fs.statSync(path).hasAccess(constants.W_OK)) {
527
+ if (config.checkAccess && !fs.statSync(path).hasAccess(constants.R_OK)) {
528
528
  throw ErrnoError.With('EACCES', path, 'link');
529
529
  }
530
530
  return fs.linkSync(path, linkPath);