added stat reading to loaders + docs and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-23 00:07:04 +03:00
parent 2f32dda3ed
commit 2dca0a85fd
5 changed files with 49 additions and 7 deletions

View File

@ -599,6 +599,8 @@ module.SortActions = actions.Actions({
// }
//
// NOTE: the cmp function is called in the actions context.
//
// XXX sequence number with overflow...
__sort_methods__: {
'name-leading-sequence': function(a, b){
a = this.images.getImageNameLeadingSeq(a)
@ -657,9 +659,14 @@ module.SortActions = actions.Actions({
// will reverse the result's order while:
// 'metadata.createDate birthtime reverse' + ' reverese'
// will cancel reversal.
// NOTE: with empty images this will not do anything.
//
// XXX this also requires images...
// XXX cache order???
// XXX would be nice to be able to sort a list of gids or a section
// of images...
// XXX sorting with partial images will throw the images that do not
// exist or the ones that do not have the right attrs all over
// the place...
sortImages: ['- Edit|Sort/Sort images',
function(method, reverse){
var that = this
@ -692,7 +699,6 @@ module.SortActions = actions.Actions({
.join(' ')
: method
method = typeof(method) == typeof('str') ? method.split(/ +/g) : method
method = method instanceof Array ? method : [method]
// get the reverse arity...
var i = method.indexOf('reverse')
@ -808,8 +814,8 @@ module.SortActions = actions.Actions({
})],
// Store/load sort data:
// .data.sort_method - current sort mode (optional)
// .manual_order - manual sort order (optional)
// .data.sort_method - current sort mode (optional)
// .data.manual_order - manual sort order (optional)
load: [function(data){
return function(){
if(data.data && data.data.sort_method){

View File

@ -141,6 +141,9 @@ module.CLI = core.ImageGridFeatures.Feature({
})
*/
// XXX might be a good idea to make the action call
// syntax like this:
// --<action-name> [args]
.arguments('<action> [args]')
.action(function(action, args){
// XXX

View File

@ -270,6 +270,7 @@ var FileSystemLoaderActions = actions.Actions({
// XXX auto-detect format or let the user chose...
// XXX should this return a promise??? ...a clean promise???
// XXX should the added section be marked or sorted???
loadPath: ['- File/Load path (STUB)',
function(path, logger){
// XXX check if this.config['index-dir'] exists, if yes then
@ -278,8 +279,6 @@ var FileSystemLoaderActions = actions.Actions({
//this.location.method = 'loadImages'
}],
// XXX merging does not work (something wrong with .data.join(..))
// ...fixed a bug in images.js hash generator, now might be fixed...
// XXX should this return a promise??? ...a clean promise???
// XXX revise logger...
loadNewImages: ['File/Load new images',
@ -298,8 +297,11 @@ var FileSystemLoaderActions = actions.Actions({
var base_pattern = RegExp('^'+path)
// find images...
glob(path + '/'+ this.config['image-file-pattern'])
glob(path + '/'+ this.config['image-file-pattern'],
{stat: !!this.config['image-file-read-stat']})
.on('end', function(lst){
var stats = this.statCache
// create a new images chunk...
lst = lst
// filter out loaded images...
@ -327,6 +329,19 @@ var FileSystemLoaderActions = actions.Actions({
var gids = new_images.keys()
var new_data = that.data.constructor.fromArray(gids)
new_images.forEach(function(gid, img){
var stat = stats[p.join(img.base_path, img.path)]
img.atime = stat.atime
img.mtime = stat.mtime
img.ctime = stat.ctime
img.birthtime = stat.birthtime
img.size = stat.size
// XXX do we need anything else???
})
// merge with index...
// NOTE: we are prepending new images to the start...
// NOTE: all ribbon gids will change here...

View File

@ -168,6 +168,8 @@ module.GLOBAL_KEYBOARD = {
// XXX need to prevent default on mac + browser...
meta: 'nextScreen',
},
Space: 'Right',
Backspace: 'Left',
'(': 'prevImageInOrder',
')': 'nextImageInOrder',
',': 'prevMarked',

View File

@ -90,6 +90,8 @@ module.Metadata = core.ImageGridFeatures.Feature({
// XXX add Metadata writer...
var MetadataReaderActions = actions.Actions({
// NOTE: this will read both stat and metadata...
//
// XXX add support to taskqueue...
// XXX should this process multiple images???
// XXX also check the metadata/ folder (???)
@ -119,6 +121,20 @@ var MetadataReaderActions = actions.Actions({
return reject(err)
}
// read stat...
if(!that.images[gid].birthtime){
var img = that.images[gid]
var stat = fs.statSync(full_path)
img.atime = stat.atime
img.mtime = stat.mtime
img.ctime = stat.ctime
img.birthtime = stat.birthtime
img.size = stat.size
}
// read image metadata...
exiftool.metadata(file, function(err, data){
if(err){
reject(err)