@@ -109,13 +109,13 @@ class tasks {
109109 }
110110
111111 _addTime ( frame , time ) {
112- return new Promise ( async function ( resolve , reject ) {
112+ return new Promise ( async function ( resolve , reject ) {
113113 let resource = this . sync . resources [ frame . resource . type ] [ frame . resource . id ] ;
114114
115115 try {
116116 await resource . createTime ( Math . ceil ( time ) ) ;
117117 await resource . getNotes ( ) ;
118- } catch ( error ) {
118+ } catch ( error ) {
119119 return reject ( error ) ;
120120 }
121121
@@ -146,24 +146,30 @@ class tasks {
146146 * @returns {Promise }
147147 */
148148 log ( ) {
149- return new Promise ( ( resolve , reject ) => {
149+ return new Promise ( async function ( resolve , reject ) {
150150 let frames = { } ,
151151 times = { } ;
152152
153- Fs . readDir ( this . config . frameDir ) . forEach ( file => {
154- let frame = Frame . fromFile ( this . config , Fs . join ( this . config . frameDir , file ) ) ;
155- if ( frame . stop === false ) return ;
156- let date = moment ( frame . start ) . format ( 'YYYY-MM-DD' ) ;
153+ try {
154+ await new FrameCollection ( this . config )
155+ . forEach ( ( frame , done ) => {
156+ if ( frame . stop === false ) return done ( ) ;
157+ let date = moment ( frame . start ) . format ( 'YYYY-MM-DD' ) ;
157158
158- if ( ! frames [ date ] ) frames [ date ] = [ ] ;
159- if ( ! times [ date ] ) times [ date ] = 0 ;
159+ if ( ! frames [ date ] ) frames [ date ] = [ ] ;
160+ if ( ! times [ date ] ) times [ date ] = 0 ;
160161
161- frames [ date ] . push ( frame ) ;
162- times [ date ] += Math . ceil ( frame . duration ) ;
163- } ) ;
162+ frames [ date ] . push ( frame ) ;
163+ times [ date ] += Math . ceil ( frame . duration ) ;
164164
165- resolve ( { frames, times} )
166- } ) ;
165+ done ( ) ;
166+ } ) ;
167+ } catch ( error ) {
168+ reject ( error ) ;
169+ }
170+
171+ resolve ( { frames, times} ) ;
172+ } . bind ( this ) ) ;
167173 }
168174
169175 /**
0 commit comments