Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
4819dd0bc5 | |||
7250793f95 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartbucket",
|
"name": "@pushrocks/smartbucket",
|
||||||
"version": "1.0.28",
|
"version": "1.0.29",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartbucket",
|
"name": "@pushrocks/smartbucket",
|
||||||
"version": "1.0.28",
|
"version": "1.0.29",
|
||||||
"description": "simple cloud independent object storage",
|
"description": "simple cloud independent object storage",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
@ -76,6 +76,14 @@ tap.test('should correctly build paths for sub directories', async () => {
|
|||||||
console.log(dir4BasePath);
|
console.log(dir4BasePath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should list huge file directory', async () => {
|
||||||
|
const servezoneBucket = await smartbucket.Bucket.getBucketByName(testSmartbucket, 'servezone');
|
||||||
|
const servezoneBaseDirectory = await servezoneBucket.getBaseDirectory();
|
||||||
|
this.brandfileDirectory = await servezoneBaseDirectory.getSubDirectoryByName('brandfiles');
|
||||||
|
const files = servezoneBaseDirectory.listFiles();
|
||||||
|
console.log(files)
|
||||||
|
});
|
||||||
|
|
||||||
tap.test('clean up directory style tests', async () => {
|
tap.test('clean up directory style tests', async () => {
|
||||||
await myBucket.fastRemove('dir1/file1.txt');
|
await myBucket.fastRemove('dir1/file1.txt');
|
||||||
await myBucket.fastRemove('dir1/file2.txt');
|
await myBucket.fastRemove('dir1/file2.txt');
|
||||||
|
@ -44,7 +44,7 @@ export class Directory {
|
|||||||
let basePath = '';
|
let basePath = '';
|
||||||
for (const parentDir of parentDirectories) {
|
for (const parentDir of parentDirectories) {
|
||||||
if (parentDir.name === '') {
|
if (parentDir.name === '') {
|
||||||
basePath = this.name;
|
basePath = this.name + '/';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
basePath = parentDir.name + '/' + this.name;
|
basePath = parentDir.name + '/' + this.name;
|
||||||
@ -57,13 +57,17 @@ export class Directory {
|
|||||||
*/
|
*/
|
||||||
public async listFiles(): Promise<File[]> {
|
public async listFiles(): Promise<File[]> {
|
||||||
const done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
const fileNameStream = await this.bucketRef.smartbucketRef.minioClient.listObjects(
|
const fileNameStream = await this.bucketRef.smartbucketRef.minioClient.listObjectsV2(
|
||||||
this.bucketRef.name,
|
this.bucketRef.name,
|
||||||
this.getBasePath()
|
this.getBasePath(),
|
||||||
|
false
|
||||||
);
|
);
|
||||||
const fileArray: File[] = [];
|
const fileArray: File[] = [];
|
||||||
const duplexStream = plugins.streamfunction.createDuplexStream<plugins.minio.BucketItem, void>(
|
const duplexStream = plugins.streamfunction.createDuplexStream<plugins.minio.BucketItem, void>(
|
||||||
async bucketItem => {
|
async bucketItem => {
|
||||||
|
if (bucketItem.prefix) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!bucketItem.name) {
|
if (!bucketItem.name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,15 +93,19 @@ export class Directory {
|
|||||||
*/
|
*/
|
||||||
public async listDirectories(): Promise<Directory[]> {
|
public async listDirectories(): Promise<Directory[]> {
|
||||||
const done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
const completeDirStream = await this.bucketRef.smartbucketRef.minioClient.listObjects(
|
const basePath = this.getBasePath();
|
||||||
|
const completeDirStream = await this.bucketRef.smartbucketRef.minioClient.listObjectsV2(
|
||||||
this.bucketRef.name,
|
this.bucketRef.name,
|
||||||
this.getBasePath(),
|
this.getBasePath(),
|
||||||
true
|
false
|
||||||
);
|
);
|
||||||
const directoryArray: Directory[] = [];
|
const directoryArray: Directory[] = [];
|
||||||
const duplexStream = plugins.streamfunction.createDuplexStream<plugins.minio.BucketItem, void>(
|
const duplexStream = plugins.streamfunction.createDuplexStream<plugins.minio.BucketItem, void>(
|
||||||
async bucketItem => {
|
async bucketItem => {
|
||||||
let subtractedPath = bucketItem.name.replace(this.getBasePath(), '');
|
if (bucketItem.name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let subtractedPath = bucketItem.prefix.replace(this.getBasePath(), '');
|
||||||
if (subtractedPath.startsWith('/')) {
|
if (subtractedPath.startsWith('/')) {
|
||||||
subtractedPath = subtractedPath.substr(1);
|
subtractedPath = subtractedPath.substr(1);
|
||||||
}
|
}
|
||||||
@ -122,7 +130,7 @@ export class Directory {
|
|||||||
* gets an array that has all objects with a certain prefix;
|
* gets an array that has all objects with a certain prefix;
|
||||||
*/
|
*/
|
||||||
public async getTreeArray() {
|
public async getTreeArray() {
|
||||||
const treeArray = await this.bucketRef.smartbucketRef.minioClient.listObjects(
|
const treeArray = await this.bucketRef.smartbucketRef.minioClient.listObjectsV2(
|
||||||
this.bucketRef.name,
|
this.bucketRef.name,
|
||||||
this.getBasePath(),
|
this.getBasePath(),
|
||||||
true
|
true
|
||||||
|
Reference in New Issue
Block a user