@zenfs/core
Advanced tools
Comparing version 0.7.4 to 0.7.5
@@ -102,2 +102,3 @@ import type { Cred } from '../cred.js'; | ||
export declare class AsyncStoreFS extends AsyncStoreFS_base { | ||
protected _options: AsyncStoreOptions; | ||
protected store: AsyncStore; | ||
@@ -109,9 +110,4 @@ private _cache?; | ||
metadata(): FileSystemMetadata; | ||
constructor(options: AsyncStoreOptions); | ||
constructor(_options: AsyncStoreOptions); | ||
/** | ||
* Initializes the file system. Typically called by subclasses' async | ||
* constructors. | ||
*/ | ||
private _initialize; | ||
/** | ||
* Delete all contents stored in the file system. | ||
@@ -118,0 +114,0 @@ */ |
@@ -56,3 +56,8 @@ import { dirname, basename, join, resolve } from '../emulation/path.js'; | ||
await super.ready(); | ||
await this._ready; | ||
if (this._options.lruCacheSize > 0) { | ||
this._cache = new LRUCache(this._options.lruCacheSize); | ||
} | ||
this.store = await this._options.store; | ||
await this.makeRootDirectory(); | ||
this._sync = this._options.sync || InMemory.create({ name: 'test' }); | ||
return this; | ||
@@ -66,19 +71,7 @@ } | ||
} | ||
constructor(options) { | ||
constructor(_options) { | ||
super(); | ||
this._ready = this._initialize(options); | ||
this._options = _options; | ||
} | ||
/** | ||
* Initializes the file system. Typically called by subclasses' async | ||
* constructors. | ||
*/ | ||
async _initialize({ store, lruCacheSize, sync }) { | ||
if (lruCacheSize > 0) { | ||
this._cache = new LRUCache(lruCacheSize); | ||
} | ||
this.store = await store; | ||
await this.makeRootDirectory(); | ||
this._sync = sync || InMemory.create({ name: 'test' }); | ||
} | ||
/** | ||
* Delete all contents stored in the file system. | ||
@@ -85,0 +78,0 @@ */ |
@@ -128,3 +128,13 @@ import { ApiError, ErrorCode } from './ApiError.js'; | ||
async ready() { | ||
await this._initialize(); | ||
if (this._isInitialized) { | ||
return this; | ||
} | ||
try { | ||
await this.crossCopy('/'); | ||
this._isInitialized = true; | ||
} | ||
catch (e) { | ||
this._isInitialized = false; | ||
throw e; | ||
} | ||
return this; | ||
@@ -207,18 +217,2 @@ } | ||
/** | ||
* Called once to load up files from async storage into sync storage. | ||
*/ | ||
async _initialize() { | ||
if (this._isInitialized) { | ||
return; | ||
} | ||
try { | ||
await this.crossCopy('/'); | ||
this._isInitialized = true; | ||
} | ||
catch (e) { | ||
this._isInitialized = false; | ||
throw e; | ||
} | ||
} | ||
/** | ||
* @internal | ||
@@ -225,0 +219,0 @@ */ |
{ | ||
"name": "@zenfs/core", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"description": "A filesystem in your browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1464882
11104