MCPcopy
hub / github.com/remotely-save/remotely-save / _init

Method _init

pro/src/fsBox.ts:318–387  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

316 }
317
318 async _init() {
319 const access = await this._getAccessToken();
320
321 if (this.vaultFolderExists) {
322 // pass
323 } else {
324 const auth = new BoxDeveloperTokenAuth({ token: access });
325 const client = new BoxClient({ auth });
326
327 // find
328 let itemsInRoot: Items | undefined = undefined;
329
330 let offset = 0;
331 const limitPerPage = 1000; // max 1000
332
333 while (!this.vaultFolderExists) {
334 itemsInRoot = await client.folders.getFolderItems("0", {
335 queryParams: {
336 fields: [
337 "id",
338 "type",
339 "name",
340 "sha1",
341 "size",
342 "created_at",
343 "modified_at",
344 "expires_at",
345 "parent",
346 "content_created_at",
347 "content_modified_at",
348 "etag",
349 ],
350 offset: offset,
351 limit: limitPerPage,
352 },
353 });
354 // console.debug(`this.remoteBaseDir=${this.remoteBaseDir}`);
355 // console.debug(`itemsInRoot:`);
356 // console.debug(itemsInRoot);
357 if (
358 (itemsInRoot.entries?.filter((x) => x.name === this.remoteBaseDir)
359 .length ?? 0) > 0
360 ) {
361 // we find it!
362 const f = itemsInRoot.entries?.filter(
363 (x) => x.name === this.remoteBaseDir
364 )[0]!;
365 this.baseDirID = f.id;
366 this.vaultFolderExists = true;
367 break;
368 }
369
370 if ((itemsInRoot.offset ?? 0) >= (itemsInRoot.totalCount ?? 0)) {
371 break;
372 }
373
374 offset += limitPerPage;
375 }

Callers 8

walkMethod · 0.95
walkPartialMethod · 0.95
statMethod · 0.95
mkdirMethod · 0.95
writeFileMethod · 0.95
readFileMethod · 0.95
rmMethod · 0.95
checkConnectMethod · 0.95

Calls 1

_getAccessTokenMethod · 0.95

Tested by

no test coverage detected