Replace usages of path with path join util.

This commit is contained in:
saul 2023-03-28 12:55:15 +13:00
parent 7ce1257cf9
commit 06a68bbe1c
7 changed files with 16 additions and 17 deletions

View File

@ -9,7 +9,7 @@ import OrbitDBAddress, { isValidAddress } from './address.js'
import DBManifest from './manifest.js'
import { createId, isDefined } from './utils/index.js'
// import Logger from 'logplease'
import path from 'path'
import pathJoin from './utils/path-join.js'
import * as Block from 'multiformats/block'
import * as dagCbor from '@ipld/dag-cbor'
import { sha256 } from 'multiformats/hashes/sha2'
@ -46,7 +46,7 @@ const OrbitDB = async ({ ipfs, id, identity, keystore, directory } = {}) => {
id = id || await createId()
const { id: peerId } = await ipfs.id()
directory = directory || './orbitdb'
keystore = keystore || await KeyStore({ path: path.join(directory, './keystore') })
keystore = keystore || await KeyStore({ path: pathJoin(directory, './keystore') })
const identities = await Identities({ ipfs, keystore })
identity = identity || await identities.createIdentity({ id })

View File

@ -1,6 +1,6 @@
import * as Path from 'path'
import { CID } from 'multiformats/cid'
import { base58btc } from 'multiformats/bases/base58'
import { posixJoin } from './utils/path-join.js'
const isValidAddress = (address) => {
address = address.toString()
@ -45,7 +45,7 @@ const OrbitDBAddress = (address) => {
const path = address.replace('/orbitdb/', '').replace('\\orbitdb\\', '')
const toString = () => {
return (Path.posix || Path).join('/', protocol, '/', path)
return posixJoin('/', protocol, path)
}
return {

View File

@ -1,8 +1,8 @@
import { EventEmitter } from 'events'
import PQueue from 'p-queue'
import Path from 'path'
import Sync from './sync.js'
import { ComposedStorage, LRUStorage, IPFSBlockStorage, LevelStorage } from './storage/index.js'
import pathJoin from './utils/path-join.js'
const defaultPointerCount = 0
const defaultCacheSize = 1000
@ -10,7 +10,7 @@ const defaultCacheSize = 1000
const Database = async ({ OpLog, ipfs, identity, address, name, accessController, directory, meta, headsStorage, entryStorage, indexStorage, pointerCount, syncAutomatically }) => {
const { Log, Entry } = OpLog
directory = Path.join(directory || './orbitdb', `./${address}/`)
directory = pathJoin(directory || './orbitdb', `./${address}/`)
meta = meta || {}
pointerCount = pointerCount || defaultPointerCount
@ -21,12 +21,12 @@ const Database = async ({ OpLog, ipfs, identity, address, name, accessController
headsStorage = headsStorage || await ComposedStorage(
await LRUStorage({ size: defaultCacheSize }),
await LevelStorage({ path: Path.join(directory, '/log/_heads/') })
await LevelStorage({ path: pathJoin(directory, '/log/_heads/') })
)
indexStorage = indexStorage || await ComposedStorage(
await LRUStorage({ size: defaultCacheSize }),
await LevelStorage({ path: Path.join(directory, '/log/_index/') })
await LevelStorage({ path: pathJoin(directory, '/log/_index/') })
)
const log = await Log(identity, { logId: address, access: accessController, entryStorage, headsStorage, indexStorage })

View File

@ -1,7 +1,7 @@
import LevelStorage from '../storage/level.js'
import { KeyValue } from './index.js'
import pathJoin from '../utils/path-join.js'
import PQueue from 'p-queue'
import path from 'path'
const valueEncoding = 'json'
@ -11,7 +11,7 @@ const KeyValuePersisted = async ({ OpLog, Database, ipfs, identity, address, nam
const queue = new PQueue({ concurrency: 1 })
directory = path.join(directory || './orbitdb', `./${address}/_index/`)
directory = pathJoin(directory || './orbitdb', `./${address}/_index/`)
const index = await LevelStorage({ path: directory, valueEncoding })
let latestOplogHash

View File

@ -4,10 +4,10 @@ import OrbitDBIdentityProvider from './providers/orbitdb.js'
// import EthIdentityProvider from './identity-providers/ethereum.js'
import KeyStore, { signMessage, verifyMessage } from '../key-store.js'
import { LRUStorage, IPFSBlockStorage, MemoryStorage, ComposedStorage } from '../storage/index.js'
import Path from 'path'
import pathJoin from '../utils/path-join.js'
const DefaultProviderType = 'orbitdb'
const DefaultIdentityKeysPath = Path.join('./orbitdb', 'identities')
const DefaultIdentityKeysPath = pathJoin('./orbitdb', 'identities')
const supportedTypes = {
orbitdb: OrbitDBIdentityProvider

View File

@ -1,5 +1,4 @@
import path from 'path'
import pathJoin from './utils/path-join.js'
import * as Block from 'multiformats/block'
import * as dagCbor from '@ipld/dag-cbor'
import { sha256 } from 'multiformats/hashes/sha2'
@ -20,7 +19,7 @@ export default async (storage, name, type, accessControllerAddress, { meta } = {
{
name,
type,
accessController: (path.posix || path).join('/ipfs', accessControllerAddress)
accessController: pathJoin('/ipfs', accessControllerAddress)
},
// meta field is only added to manifest if meta parameter is defined
meta !== undefined ? { meta } : {}

View File

@ -1,8 +1,8 @@
import { pipe } from 'it-pipe'
import PQueue from 'p-queue'
import Path from 'path'
import { EventEmitter } from 'events'
import { TimeoutController } from 'timeout-abort-controller'
import pathJoin from './utils/path-join.js'
const DefaultTimeout = 30000 // 30 seconds
@ -46,7 +46,7 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
if (!log) throw new Error('An instance of log is required.')
const address = log.id
const headsSyncAddress = Path.join('/orbitdb/heads/', address)
const headsSyncAddress = pathJoin('/orbitdb/heads/', address)
const queue = new PQueue({ concurrency: 1 })
const peers = new Set()