File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -107,18 +107,23 @@ function postAddScraper(req, res)
107
107
108
108
case "sitemap-created" :
109
109
110
- var sitemap_path = "public/sitemaps/sitemap_" + data . host + ".xml" ;
111
- fs . writeFile ( sitemap_path , data . content , function ( err )
112
- {
113
- if ( err )
114
- console . log ( err ) ;
115
- else
116
- io . sockets . emit ( 'sitemap-ready' , { path : sitemap_path . replace ( "public/" , "" ) } )
117
-
118
- // Terminate crawling daemon
119
- child . kill ( ) ;
120
- } ) ;
121
-
110
+ var sitemap_path = "public/sitemaps/" ;
111
+ fs . exists ( sitemap_path , function ( exists ) {
112
+ if ( ! exists ) {
113
+ fs . mkdir ( sitemap_path ) ;
114
+ }
115
+ var filename = "sitemap_" + data . host + ".xml" ;
116
+ fs . writeFile ( sitemap_path + filename , data . content , function ( err )
117
+ {
118
+ if ( err )
119
+ console . log ( err ) ;
120
+ else
121
+ io . sockets . emit ( 'sitemap-ready' , { path : sitemap_path . replace ( "public/" , "" ) } )
122
+
123
+ // Terminate crawling daemon
124
+ child . kill ( ) ;
125
+ } ) ;
126
+ } ) ;
122
127
break ;
123
128
}
124
129
} )
You can’t perform that action at this time.
0 commit comments