MCPcopy
hub / github.com/jvilk/BrowserFS / AsyncMirror

Class AsyncMirror

src/backend/AsyncMirror.ts:89–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87 * ```
88 */
89export default class AsyncMirror extends SynchronousFileSystem implements FileSystem {
90 public static readonly Name = "AsyncMirror";
91
92 public static readonly Options: FileSystemOptions = {
93 sync: {
94 type: "object",
95 description: "The synchronous file system to mirror the asynchronous file system to."
96 },
97 async: {
98 type: "object",
99 description: "The asynchronous file system to mirror."
100 }
101 };
102
103 /**
104 * Constructs and initializes an AsyncMirror file system with the given options.
105 */
106 public static Create(opts: AsyncMirrorOptions, cb: BFSCallback<AsyncMirror>): void {
107 try {
108 const fs = new AsyncMirror(opts.sync, opts.async, false);
109 fs.initialize((e?) => {
110 if (e) {
111 cb(e);
112 } else {
113 cb(null, fs);
114 }
115 }, false);
116 } catch (e) {
117 cb(e);
118 }
119 }
120
121 public static isAvailable(): boolean {
122 return true;
123 }
124
125 /**
126 * Queue of pending asynchronous operations.
127 */
128 private _queue: IAsyncOperation[] = [];
129 private _queueRunning: boolean = false;
130 private _sync: FileSystem;
131 private _async: FileSystem;
132 private _isInitialized: boolean = false;
133 private _initializeCallbacks: ((e?: ApiError) => void)[] = [];
134
135 /**
136 * **Deprecated; use AsyncMirror.Create() method instead.**
137 *
138 * Mirrors the synchronous file system into the asynchronous file system.
139 *
140 * **IMPORTANT**: You must call `initialize` on the file system before it can be used.
141 * @param sync The synchronous file system to mirror the asynchronous file system to.
142 * @param async The asynchronous file system to mirror.
143 */
144 constructor(sync: FileSystem, async: FileSystem, deprecateMsg = true) {
145 super();
146 this._sync = sync;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected