This commit is contained in:
v 2018-07-17 17:42:50 +03:00
parent a6402e43fb
commit c090ba9028

View File

@ -85,6 +85,10 @@ function log ( ...args ) {
console.log( elapsedStr( startTime ), ... args ) console.log( elapsedStr( startTime ), ... args )
} }
function warn ( ...args ) {
log( ...args )
}
function fatal ( ...args ) { function fatal ( ...args ) {
log( ...args ) log( ...args )
osProcess.exit( 1 ) osProcess.exit( 1 )
@ -384,7 +388,7 @@ class WikiItem {
return Promise.reject( new Error( 'data == null' )) return Promise.reject( new Error( 'data == null' ))
const savePath = wiki.saveDir + this.localPath() const savePath = wiki.saveDir + this.localPath()
log( '>', savePath ) log( '+', savePath )
return fs.outputFile( savePath, data ) return fs.outputFile( savePath, data )
.then( () => this.localPath() ) .then( () => this.localPath() )
@ -416,7 +420,7 @@ class WikiItem {
.then( () => this.storeMetadata() ) .then( () => this.storeMetadata() )
.then( () => this.localPath() ) .then( () => this.localPath() )
.catch( err => { .catch( err => {
console.warn( 'Save error', err.name, err.message, this.url, '->', this.localPath()) warn( 'Save error', err.name, err.message, this.url, '->', this.localPath())
return '' return ''
}) })
} }
@ -601,7 +605,7 @@ class Redirect extends ArticleStub {
this.toFragment, this.toFragment,
] ]
log( '-->', this.title || this.url, row) log( '>', this.title || this.url, row)
indexerDb.run( indexerDb.run(
'INSERT INTO redirects (id, targetKey, fragment) VALUES (?,?,?)', 'INSERT INTO redirects (id, targetKey, fragment) VALUES (?,?,?)',
@ -997,7 +1001,7 @@ function batchPages () {
} }
const pageInfo = pages[ key ] const pageInfo = pages[ key ]
if ( pageInfo.redirect != null ) { if ( pageInfo.redirect != null ) {
log( '>>>' , pageInfo.title ) log( '>' , pageInfo.title )
redirects.push( pageInfo ) redirects.push( pageInfo )
if ( redirects.length == queryMaxTitles ) { if ( redirects.length == queryMaxTitles ) {
const res = batchRedirects( redirects ) const res = batchRedirects( redirects )
@ -1007,9 +1011,10 @@ function batchPages () {
return null return null
} }
if ( ! command.pages ) { if ( ! command.pages ) {
log( 'x' , pageInfo.title )
return null return null
} }
log( '---', pageInfo.title ) log( '#', pageInfo.title )
return new Article( pageInfo ).process() return new Article( pageInfo ).process()
}) })
done.push( batchRedirects( redirects )) done.push( batchRedirects( redirects ))