rethinking the fs module...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-12-07 02:28:33 +03:00
parent 64095d10b5
commit 26f9c46105
4 changed files with 33 additions and 15 deletions

View File

@ -2097,6 +2097,9 @@ module.CollectionTags = core.ImageGridFeatures.Feature({
})
}],
// load collection local tags from .data.tags to .local_tags...
// ...this is needed if the collections are fully loaded as part
// of the index...
// XXX do we actually need this???
['load',
function(_, json){
var that = this
@ -2109,17 +2112,17 @@ module.CollectionTags = core.ImageGridFeatures.Feature({
// do the loading...
.forEach(function(title){
var c = that.collections[title]
if(!c){
if(!c || !c.data){
return
}
var t = (c.data || {}).tags || {}
/* XXX do we need this???
c.local_tags = c.local_tags || {}
var t = (c.data.tags || {}).tags || {}
var lt = c.local_tags = c.local_tags || {}
;(that.config['collection-local-tags'] || [])
.forEach(function(tag){
c.local_tags[tag] = new Set(c.local_tags[tag] || t[tag] || []) })
//*/
lt[tag] = new Set(lt[tag] || t[tag] || []) })
})
}],
],

View File

@ -1038,7 +1038,7 @@ var CommentsActions = actions.Actions({
// ...
// },
//
// <keywork>: <data>,
// <keyword>: <data>,
// ...
// }
__comments: null,
@ -1158,22 +1158,24 @@ var FileSystemCommentsActions = actions.Actions({
return Promise.all(loaded.map(function(path){
var comments_dir = that.config['index-dir'] +'/comments'
return file.loadIndex(path, that.config['index-dir'] +'/comments', date, logger)
return file.loadIndex(path +'/'+ comments_dir, false, date, logger)
.then(function(res){
var c = res[path +'/'+ comments_dir]
// no comments present...
if(res[path] == null){
if(c == null){
return res
}
// if we have no sub-indexes just load the
// comments as-is...
if(loaded.length == 1){
that.comments = JSON.parse(JSON.stringify(res[path]))
that.comments.raw = {path: res[path]}
that.comments = JSON.parse(JSON.stringify(c))
that.comments.raw = {path: c}
// sub-indexes -> let the client merge their stuff...
} else {
that.comments.raw[path] = res[path]
that.comments.raw[path] = c
}
return res
@ -1287,9 +1289,19 @@ var FileSystemSaveHistoryActions = actions.Actions({
loadSaveHistoryList: ['- File/',
function(path){
path = path || this.location.path
var index_dir = this.config['index-dir']
path = path || this.location.loaded
path = path instanceof Array ? path : [path]
return file.loadSaveHistoryList(path)
var res = {}
return Promise
.all(this.location.loaded
.map(function(path){
return file.loadSaveHistoryList(path +'/'+ index_dir)
.then(function(data){
res[path] = data }) }))
.then(function(){
return res })
}],
})

View File

@ -177,8 +177,9 @@ core.ImageGridFeatures.Feature('imagegrid-testing', [
//----------------------------------------------------- testing ---
'experiments',
'-tests',
// XXX this is really slow on load, need to speed the search up...
'-comments',
//'-comments',
// missing suggested feature test -- should show up in .features.missing...
'missing-feature',

View File

@ -354,6 +354,8 @@ function(path, index_dir, logger){
.on('end', function(files){
var data = groupByDate(files)
console.log('>>>>>', data)
// XXX should we mark the root timestamp in any way???
if('root' in data && data.root.length > 0){
// XXX handle stat error...