found a bug in .exportIndex(..), partially fixed...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-11-02 04:05:32 +03:00
parent ce1e3375a7
commit 3d306a982c

View File

@ -1748,6 +1748,13 @@ var FileSystemWriterActions = actions.Actions({
// XXX what should happen if no path is given??? // XXX what should happen if no path is given???
// XXX handle .image.path and other stack files... // XXX handle .image.path and other stack files...
// XXX local collections??? // XXX local collections???
//
// XXX BUG: this does not remove previews correctly...
// to reproduce:
// open: L:\media\img\my\2019
// exportIndex: with max_size=400
// -> main preview is not replaced
// -> preivew size 350px not copied but kept in index...
exportIndex: ['- File/Export/Export index', exportIndex: ['- File/Export/Export index',
function(path, max_size, include_orig, clean_target_dir, logger){ function(path, max_size, include_orig, clean_target_dir, logger){
var that = this var that = this
@ -1854,8 +1861,7 @@ var FileSystemWriterActions = actions.Actions({
.slice(0, -1) .slice(0, -1)
.join('.') .join('.')
// other name... // other name...
: img.name : img.name }
}
// update path... // update path...
to_path = img.path = pathlib.join(base, name) to_path = img.path = pathlib.join(base, name)
@ -1886,13 +1892,15 @@ var FileSystemWriterActions = actions.Actions({
// no size limit or match... // no size limit or match...
if(!max_size || parseInt(res) <= max_size){ if(!max_size || parseInt(res) <= max_size){
// get the biggest remaining preview... // get the biggest remaining preview...
max = max == null || parseInt(res) > parseInt(max) ? max = (max == null
|| parseInt(res) > parseInt(max)) ?
res res
: max : max
return true return true
} }
// skip and remove... // skip and remove...
delete previews[res]
replace_orig = true replace_orig = true
}) })
// get paths... // get paths...
@ -1960,7 +1968,6 @@ var FileSystemWriterActions = actions.Actions({
.catch(function(err){ .catch(function(err){
logger && logger.emit('error', err) })) logger && logger.emit('error', err) }))
} }
}) })
} }
}) })
@ -1970,21 +1977,21 @@ var FileSystemWriterActions = actions.Actions({
// NOTE: if we are to use .saveIndex(..) here, do not forget // NOTE: if we are to use .saveIndex(..) here, do not forget
// to reset .changes // to reset .changes
queue.push(file.writeIndex( queue.push(
index.index, file.writeIndex(
index_path, index.index,
index.date, index_path,
this.config['index-filename-template'], index.date,
logger) this.config['index-filename-template'],
//logger || this.logger) logger)
//logger || this.logger)
// set hidden file attribute on Windows... // set hidden file attribute on Windows...
.then(function(){ .then(function(){
typeof(process) != 'undefined' typeof(process) != 'undefined'
&& (process.platform == 'win32' && (process.platform == 'win32'
|| process.platform == 'win64') || process.platform == 'win64')
&& child_process && child_process
.spawn('attrib', ['+h', index_path]) .spawn('attrib', ['+h', index_path]) }))
}))
return Promise.all(queue) return Promise.all(queue)
}], }],