-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(snapshot): remove obsolete snap
- Loading branch information
Showing
33 changed files
with
300 additions
and
1,611 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { BucketAbstract } from '~/libraries/Files/remote/abstracts/Bucket.abstract' | ||
import { Config } from '~/config' | ||
import { | ||
FILESYSTEM_TYPE, | ||
SharedBucketIndex, | ||
} from '~/libraries/Files/types/filesystem' | ||
|
||
export class SharedBucket extends BucketAbstract { | ||
private _index: SharedBucketIndex = { | ||
type: FILESYSTEM_TYPE.DEFAULT, | ||
version: 1, | ||
content: [], | ||
} | ||
|
||
/** | ||
* @getter | ||
* @returns file system export data | ||
*/ | ||
get index(): SharedBucketIndex { | ||
return this._index | ||
} | ||
|
||
/** | ||
* @method init | ||
* @description Initializes bucket | ||
* @param name bucket name | ||
*/ | ||
async init({ name }: { name: string }) { | ||
await this.getBucket({ name }) | ||
if (!this._buckets || !this._key) { | ||
throw new Error('Bucket or bucket key not found') | ||
} | ||
// todo - add index tracking capabilities to shared bucket | ||
// try { | ||
// const data = [] | ||
// for await (const bytes of this._buckets.pullPath( | ||
// this._key, | ||
// Config.textile.fsTable, | ||
// )) { | ||
// data.push(bytes) | ||
// } | ||
// this._index = JSON.parse( | ||
// await new Blob(data, { | ||
// type: 'application/json', | ||
// }).text(), | ||
// ) | ||
// } catch (e) { | ||
// console.log(e) | ||
// } | ||
} | ||
|
||
/** | ||
* @method updateIndex | ||
* @param index SharedBucketIndex | ||
* @description sets index data and root | ||
*/ | ||
async updateIndex(index: SharedBucketIndex) { | ||
if (!this._buckets || !this._key) { | ||
throw new Error('Bucket or bucket key not found') | ||
} | ||
this._index = index | ||
const res = await this._buckets.pushPath( | ||
this._key, | ||
Config.textile.fsTable, | ||
Buffer.from(JSON.stringify(index)), | ||
{ root: this._root }, | ||
) | ||
this._root = res.root | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.