@zenfs/core 0.5.0 → 0.5.2

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.
@@ -57,6 +57,10 @@ export declare enum ErrorCode {
57
57
  * Cannot modify a read-only file system
58
58
  */
59
59
  EROFS = 30,
60
+ /**
61
+ * Resource deadlock would occur
62
+ */
63
+ EDEADLK = 35,
60
64
  /**
61
65
  * Directory is not empty
62
66
  */
package/dist/ApiError.js CHANGED
@@ -57,6 +57,10 @@ export var ErrorCode;
57
57
  * Cannot modify a read-only file system
58
58
  */
59
59
  ErrorCode[ErrorCode["EROFS"] = 30] = "EROFS";
60
+ /**
61
+ * Resource deadlock would occur
62
+ */
63
+ ErrorCode[ErrorCode["EDEADLK"] = 35] = "EDEADLK";
60
64
  /**
61
65
  * Directory is not empty
62
66
  */
@@ -84,6 +88,7 @@ export const ErrorStrings = {
84
88
  [ErrorCode.EFBIG]: 'File is too big.',
85
89
  [ErrorCode.ENOSPC]: 'No space left on disk.',
86
90
  [ErrorCode.EROFS]: 'Cannot modify a read-only file system.',
91
+ [ErrorCode.EDEADLK]: 'Resource deadlock would occur',
87
92
  [ErrorCode.ENOTEMPTY]: 'Directory is not empty.',
88
93
  [ErrorCode.ENOTSUP]: 'Operation is not supported.',
89
94
  };
@@ -85,5 +85,5 @@ export declare function isBackendConfig(arg: unknown): arg is BackendConfig;
85
85
  * Retrieve a file system with the given configuration.
86
86
  * @param config A BackendConfig object.
87
87
  */
88
- export declare function resolveBackendConfig(options: BackendConfig): Promise<FileSystem>;
88
+ export declare function resolveBackend(options: BackendConfig, _depth?: number): Promise<FileSystem>;
89
89
  export {};
@@ -59,7 +59,7 @@ export function isBackendConfig(arg) {
59
59
  * Retrieve a file system with the given configuration.
60
60
  * @param config A BackendConfig object.
61
61
  */
62
- export async function resolveBackendConfig(options) {
62
+ export async function resolveBackend(options, _depth = 0) {
63
63
  if (typeof options !== 'object' || options == null) {
64
64
  throw new ApiError(ErrorCode.EINVAL, 'Invalid options on configuration object.');
65
65
  }
@@ -74,7 +74,10 @@ export async function resolveBackendConfig(options) {
74
74
  option = { backend: option };
75
75
  }
76
76
  if (isBackendConfig(option)) {
77
- options[prop] = await resolveBackendConfig(option);
77
+ if (_depth > 10) {
78
+ throw new ApiError(ErrorCode.EINVAL, 'Invalid configuration, too deep and possibly infinite');
79
+ }
80
+ options[prop] = await resolveBackend(option, ++_depth);
78
81
  }
79
82
  }
80
83
  if (!(await backend.isAvailable())) {