-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
88 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
var fs = require('fs') | ||
var path = require('path') | ||
var ram = require('random-access-memory') | ||
var datStore = require('dat-storage') | ||
// var datStore = require('dat-storage') | ||
var mkdirp = require('mkdirp') | ||
|
||
module.exports = storage | ||
|
||
function storage (dir, opts) { | ||
if (opts.temp) return ram | ||
if (typeof opts.sleep === 'string') return opts.sleep | ||
|
||
mkdirp.sync(dir) | ||
try { | ||
var isDir = fs.statSync(dir).isDirectory() | ||
if (isDir) return datStore(dir) | ||
error() | ||
} catch (e) { | ||
throw e | ||
} | ||
|
||
function error () { | ||
// TODO: single file sleep storage | ||
throw new Error('Specify dir for sleep files: --sleep <dir>') | ||
} | ||
var datDir = path.join(dir, '.dat') | ||
mkdirp.sync(datDir) | ||
return datDir | ||
// TODO dat-storage | ||
// try { | ||
// var isDir = fs.statSync(dir).isDirectory() | ||
// if (isDir) return datStore(dir) | ||
// error() | ||
// } catch (e) { | ||
// throw e | ||
// } | ||
// function error () { | ||
// // TODO: single file sleep storage | ||
// throw new Error('Specify dir for sleep files: --sleep <dir>') | ||
// } | ||
} |
Oops, something went wrong.