@genoacms/adapter-gcp 0.5.2-fix.8 → 0.5.2-fix.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
|
|
1
1
|
import { getBucket } from './storage.js';
|
2
|
+
import { join } from 'path';
|
2
3
|
const getObject = async ({ bucket, name }) => {
|
3
4
|
const bucketInstance = getBucket(bucket);
|
4
5
|
const file = bucketInstance.file(name);
|
@@ -34,7 +35,7 @@ const listDirectory = async ({ bucket, name }, listingParams = {}) => {
|
|
34
35
|
const bucketInstance = getBucket(bucket);
|
35
36
|
const options = {
|
36
37
|
autoPaginate: false,
|
37
|
-
prefix: name,
|
38
|
+
prefix: join(name, '/'),
|
38
39
|
maxResults: listingParams?.limit,
|
39
40
|
startOffset: listingParams?.startAfter,
|
40
41
|
delimiter: '/'
|
@@ -50,7 +51,7 @@ const listDirectory = async ({ bucket, name }, listingParams = {}) => {
|
|
50
51
|
lastModified: new Date(file.metadata.updated)
|
51
52
|
};
|
52
53
|
}),
|
53
|
-
directories: apiResponse?.prefixes ?? []
|
54
|
+
directories: (apiResponse?.prefixes ?? []).filter((item) => item !== name)
|
54
55
|
};
|
55
56
|
};
|
56
57
|
const createDirectory = async ({ bucket, name }) => {
|
package/package.json
CHANGED
@@ -4,6 +4,7 @@ import type {
|
|
4
4
|
} from '@genoacms/cloudabstraction/storage'
|
5
5
|
import { type File } from '@google-cloud/storage'
|
6
6
|
import { getBucket } from './storage.js'
|
7
|
+
import { join } from 'path'
|
7
8
|
|
8
9
|
const getObject: Adapter.getObject = async ({ bucket, name }) => {
|
9
10
|
const bucketInstance = getBucket(bucket)
|
@@ -46,7 +47,7 @@ const listDirectory: Adapter.listDirectory = async ({ bucket, name }, listingPar
|
|
46
47
|
const bucketInstance = getBucket(bucket)
|
47
48
|
const options = {
|
48
49
|
autoPaginate: false,
|
49
|
-
prefix: name,
|
50
|
+
prefix: join(name, '/'),
|
50
51
|
maxResults: listingParams?.limit,
|
51
52
|
startOffset: listingParams?.startAfter,
|
52
53
|
delimiter: '/'
|
@@ -65,7 +66,7 @@ const listDirectory: Adapter.listDirectory = async ({ bucket, name }, listingPar
|
|
65
66
|
lastModified: new Date(file.metadata.updated as string)
|
66
67
|
} satisfies StorageObject
|
67
68
|
}),
|
68
|
-
directories: apiResponse?.prefixes ?? []
|
69
|
+
directories: (apiResponse?.prefixes ?? []).filter((item) => item !== name)
|
69
70
|
}
|
70
71
|
}
|
71
72
|
|