Skip to content

Commit 3d8045d

Browse files
committed
small fix
1 parent 11c7f30 commit 3d8045d

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/components/core/handler/persistentStorage.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ export class PersistentStorageCreateBucketHandler extends CommandHandler {
7070
const node = this.getOceanNode()
7171
const config = node.getConfig()
7272
// if we have access lists,check them.
73-
if (config.persistentStorage?.accessLists) {
73+
if (
74+
config.persistentStorage?.accessLists &&
75+
config.persistentStorage?.accessLists.length > 0
76+
) {
7477
const isAllowedCreate = await checkAddressOnAccessList(
7578
task.consumerAddress,
7679
config.persistentStorage?.accessLists,

src/components/persistentStorage/PersistentStorageLocalFS.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
PersistentStorageFileInfo
1919
} from './PersistentStorageFactory.js'
2020
import { OceanNode } from '../../OceanNode.js'
21+
import { CORE_LOGGER } from '../../utils/logging/common.js'
2122

2223
export class PersistentStorageLocalFS extends PersistentStorageFactory {
2324
/* eslint-disable security/detect-non-literal-fs-filename -- localfs backend operates on filesystem paths */
@@ -29,7 +30,26 @@ export class PersistentStorageLocalFS extends PersistentStorageFactory {
2930
.options as PersistentStorageLocalFSOptions
3031

3132
this.baseFolder = options.folder
32-
fsp.mkdir(this.baseFolder, { recursive: true })
33+
34+
// Ensure base folder exists and is a directory (sync to avoid startup races).
35+
try {
36+
fs.mkdirSync(this.baseFolder, { recursive: true })
37+
const st = fs.statSync(this.baseFolder)
38+
if (!st.isDirectory()) {
39+
throw new Error(
40+
`Persistent storage folder is not a directory: ${this.baseFolder}`
41+
)
42+
}
43+
fs.mkdirSync(path.join(this.baseFolder, 'buckets'), { recursive: true })
44+
} catch (e: any) {
45+
if (e?.code === 'EACCES') {
46+
throw new Error(
47+
`Persistent storage folder is not accessible (EACCES): ${this.baseFolder}. ` +
48+
`Configure 'persistentStorage.options.folder' to a writable path inside the container and mount it as a volume.`
49+
)
50+
}
51+
throw e
52+
}
3353
}
3454

3555
private bucketPath(bucketId: string): string {
@@ -78,7 +98,9 @@ export class PersistentStorageLocalFS extends PersistentStorageFactory {
7898
): Promise<CreateBucketResult> {
7999
const bucketId = randomUUID()
80100
const createdAt = Math.floor(Date.now() / 1000)
81-
await fsp.mkdir(this.bucketPath(bucketId), { recursive: true })
101+
const path = this.bucketPath(bucketId)
102+
CORE_LOGGER.debug(`Creating ${path} folder for new bucket`)
103+
await fsp.mkdir(path)
82104
await super.dbUpsertBucket(
83105
bucketId,
84106
owner,

0 commit comments

Comments
 (0)