Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function setup () {
// open databases
dbPath = path.join(app.getPath('userData'), 'Hyperdrive')
mkdirp.sync(path.join(dbPath, 'Archives')) // make sure the folders exist
db = level(dbPath)
archiveMetaDb = subleveldown(db, 'archive-meta', { valueEncoding: 'json' })
subscribedArchivesDb = subleveldown(db, 'subscribed-archives', { valueEncoding: 'json' })
ownedArchivesDb = subleveldown(db, 'owned-archives', { valueEncoding: 'json' })
drive = hyperdrive(db)
// watch archives for FS changes
var watcher = chokidar.watch(path.join(dbPath, 'Archives'), { persistent: true, cwd: path.join(dbPath, 'Archives') })
watcher.on('ready', () => { // wait till ready, otherwise we get an 'add' for each existing file
watcher.on('add', onArchiveFSChange.bind(null, 'add', 'file'))
watcher.on('addDir', onArchiveFSChange.bind(null, 'add', 'directory'))
watcher.on('change', onArchiveFSChange.bind(null, 'change', 'file'))
// watcher.on('unlink', onArchiveFSChange.bind(null, 'unlink', 'file')) TODO: dat doesnt support deletes yet
// watcher.on('unlinkDir', onArchiveFSChange.bind(null, 'unlink', 'directory')) TODO: dat doesnt support deletes yet
})
app.once('will-quit', () => watcher.close())
// create webrtc
wrtc = electronWebrtc()
wrtc.on('error', err => log('[WRTC]', err))
export function setup () {
// open databases
dbPath = path.join(app.getPath('userData'), 'Hyperdrive')
mkdirp.sync(path.join(dbPath, 'Archives')) // make sure the folders exist
db = level(dbPath)
archiveMetaDb = subleveldown(db, 'archive-meta', { valueEncoding: 'json' })
subscribedArchivesDb = subleveldown(db, 'subscribed-archives', { valueEncoding: 'json' })
ownedArchivesDb = subleveldown(db, 'owned-archives', { valueEncoding: 'json' })
drive = hyperdrive(db)
// watch archives for FS changes
var watcher = chokidar.watch(path.join(dbPath, 'Archives'), { persistent: true, cwd: path.join(dbPath, 'Archives') })
watcher.on('ready', () => { // wait till ready, otherwise we get an 'add' for each existing file
watcher.on('add', onArchiveFSChange.bind(null, 'add', 'file'))
watcher.on('addDir', onArchiveFSChange.bind(null, 'add', 'directory'))
watcher.on('change', onArchiveFSChange.bind(null, 'change', 'file'))
// watcher.on('unlink', onArchiveFSChange.bind(null, 'unlink', 'file')) TODO: dat doesnt support deletes yet
// watcher.on('unlinkDir', onArchiveFSChange.bind(null, 'unlink', 'directory')) TODO: dat doesnt support deletes yet
})
app.once('will-quit', () => watcher.close())
// create webrtc
export function setup () {
// open databases
dbPath = path.join(app.getPath('userData'), 'Hyperdrive')
mkdirp.sync(path.join(dbPath, 'Archives')) // make sure the folders exist
db = level(dbPath)
archiveMetaDb = subleveldown(db, 'archive-meta', { valueEncoding: 'json' })
subscribedArchivesDb = subleveldown(db, 'subscribed-archives', { valueEncoding: 'json' })
ownedArchivesDb = subleveldown(db, 'owned-archives', { valueEncoding: 'json' })
drive = hyperdrive(db)
// watch archives for FS changes
var watcher = chokidar.watch(path.join(dbPath, 'Archives'), { persistent: true, cwd: path.join(dbPath, 'Archives') })
watcher.on('ready', () => { // wait till ready, otherwise we get an 'add' for each existing file
watcher.on('add', onArchiveFSChange.bind(null, 'add', 'file'))
watcher.on('addDir', onArchiveFSChange.bind(null, 'add', 'directory'))
watcher.on('change', onArchiveFSChange.bind(null, 'change', 'file'))
// watcher.on('unlink', onArchiveFSChange.bind(null, 'unlink', 'file')) TODO: dat doesnt support deletes yet
// watcher.on('unlinkDir', onArchiveFSChange.bind(null, 'unlink', 'directory')) TODO: dat doesnt support deletes yet
})
app.once('will-quit', () => watcher.close())
// create webrtc
wrtc = electronWebrtc()
constructor({ identity, virgilCrypto, leveldown }: GroupLocalStorageConstructorParams) {
this._encryptionLevel = new VirgilEncryptDown(leveldown, { virgilCrypto });
const rootLevel = levelup(this._encryptionLevel);
const identityLevel = sub(rootLevel, identity);
this._db = sub(identityLevel, 'GROUPS', { valueEncoding: 'json' });
}
constructor({ identity, virgilCrypto, leveldown }: GroupLocalStorageConstructorParams) {
this._encryptionLevel = new VirgilEncryptDown(leveldown, { virgilCrypto });
const rootLevel = levelup(this._encryptionLevel);
const identityLevel = sub(rootLevel, identity);
this._db = sub(identityLevel, 'GROUPS', { valueEncoding: 'json' });
}