@@ -2,16 +2,9 @@ var stream = require('stream')
2
2
3
3
module . exports = function ( node ) {
4
4
var store = { }
5
- var baseDir = '/ipfs-blob-store/'
6
- store . baseDir = baseDir
5
+ store . baseDir = '/'
7
6
store . node = node
8
7
9
- node . files . mkdir ( baseDir , { p : true } , function ( err ) {
10
- if ( err ) {
11
- console . error ( err )
12
- }
13
- } )
14
-
15
8
store . createWriteStream = function ( opts , cb ) {
16
9
if ( typeof opts === 'string' ) opts = { key : opts }
17
10
if ( opts . name ) opts . key = opts . name
@@ -33,7 +26,7 @@ module.exports = function (node) {
33
26
var dirPath = opts . key . split ( '/' )
34
27
dirPath . pop ( )
35
28
dirPath = dirPath . join ( '/' )
36
- node . files . mkdir ( baseDir + dirPath , { p : true } , function ( err ) {
29
+ node . files . mkdir ( store . baseDir + dirPath , { p : true } , function ( err ) {
37
30
if ( err ) {
38
31
console . error ( err )
39
32
return cb ( err )
@@ -45,12 +38,12 @@ module.exports = function (node) {
45
38
}
46
39
47
40
function writeBuf ( ) {
48
- node . files . write ( baseDir + opts . key , buffer , { e : true } , function ( err ) {
41
+ node . files . write ( store . baseDir + opts . key , buffer , { e : true } , function ( err ) {
49
42
if ( err ) {
50
43
return cb ( err )
51
44
}
52
45
53
- node . files . stat ( baseDir + opts . key , function ( err , res ) {
46
+ node . files . stat ( store . baseDir + opts . key , function ( err , res ) {
54
47
if ( err ) {
55
48
return cb ( err )
56
49
}
@@ -76,7 +69,7 @@ module.exports = function (node) {
76
69
77
70
var passThrough = new stream . PassThrough ( )
78
71
79
- node . files . read ( baseDir + opts . key , { } , function ( err , stream ) {
72
+ node . files . read ( store . baseDir + opts . key , { } , function ( err , stream ) {
80
73
if ( err ) {
81
74
return passThrough . emit ( 'error' , err )
82
75
}
@@ -92,7 +85,7 @@ module.exports = function (node) {
92
85
if ( opts . name ) opts . key = opts . name
93
86
if ( ! cb ) cb = noop
94
87
95
- node . files . stat ( baseDir + opts . key , { } , function ( err , res ) {
88
+ node . files . stat ( store . baseDir + opts . key , { } , function ( err , res ) {
96
89
if ( err ) {
97
90
if ( err . code === 0 ) {
98
91
return cb ( null , false )
@@ -109,7 +102,7 @@ module.exports = function (node) {
109
102
if ( opts . name ) opts . key = opts . name
110
103
if ( ! cb ) cb = noop
111
104
112
- node . files . rm ( baseDir + opts . key , { } , function ( err ) {
105
+ node . files . rm ( store . baseDir + opts . key , { } , function ( err ) {
113
106
if ( err ) {
114
107
console . log ( err )
115
108
return cb ( err )
0 commit comments