@@ -140,35 +140,42 @@ var crypto = require('crypto');
140
140
common . db . collection ( "metric_changes" + app_id ) . remove ( { uid : { $in : res [ 0 ] . uid } } , function ( err , result ) {
141
141
plugins . dispatch ( "/i/app_users/delete" , { app_id :app_id , query :query , uids :res [ 0 ] . uid , params :params } , function ( ) {
142
142
common . db . collection ( "app_users" + app_id ) . remove ( { uid : { $in : res [ 0 ] . uid } } , function ( err , result ) {
143
- for ( var i = 0 ; i < res [ 0 ] . exported . length ; i ++ ) //delete exports if exist
143
+ if ( res [ 0 ] . exported )
144
144
{
145
- if ( res [ 0 ] . exported [ i ] . substr ( res [ 0 ] . exported [ i ] . length - 7 ) == ".tar.gz" )
145
+ for ( var i = 0 ; i < res [ 0 ] . exported . length ; i ++ ) //delete exports if exist
146
146
{
147
- if ( fs . existsSync ( res [ 0 ] . exported [ i ] ) ) {
148
- try { fs . unlinkSync ( res [ 0 ] . exported [ i ] ) ; } catch ( err ) { callback ( err , "" ) ; }
147
+ if ( res [ 0 ] . exported [ i ] . substr ( res [ 0 ] . exported [ i ] . length - 7 ) == ".tar.gz" )
148
+ {
149
+ if ( fs . existsSync ( res [ 0 ] . exported [ i ] ) ) {
150
+ try { fs . unlinkSync ( res [ 0 ] . exported [ i ] ) ; } catch ( err ) { console . log ( err ) ; }
151
+ }
149
152
}
150
- }
151
- else
152
- {
153
- if ( fs . existsSync ( res [ 0 ] . exported [ i ] ) )
153
+ else
154
154
{
155
- fse . remove ( res [ 0 ] . exported [ i ] ,
156
- err => {
157
- if ( err ) { console . log ( err ) ; }
158
- }
159
- ) ;
155
+ if ( fs . existsSync ( res [ 0 ] . exported [ i ] ) )
156
+ {
157
+ fse . remove ( res [ 0 ] . exported [ i ] ,
158
+ err => {
159
+ if ( err ) { console . log ( err ) ; }
160
+ }
161
+ ) ;
162
+ }
160
163
}
161
164
}
162
165
}
163
166
//deleting userimages(if they exist);
164
- for ( var i = 0 ; i < res [ 0 ] . picture . length ; i ++ ) //delete exports if exist
167
+ if ( res [ 0 ] . picure )
165
168
{
166
- //remove /userimages/
167
- var id = res [ 0 ] . picture [ i ] . substr ( 12 , res [ 0 ] . picture [ i ] . length - 12 ) ;
168
- var pp = path . resolve ( __dirname , './../../../frontend/express/public/userimages/' + id ) ;
169
- countlyFs . deleteFile ( "userimages" , pp , { id :id } , function ( err ) {
170
- console . log ( err ) ;
171
- } ) ;
169
+ for ( var i = 0 ; i < res [ 0 ] . picture . length ; i ++ ) //delete exports if exist
170
+ {
171
+ //remove /userimages/
172
+ var id = res [ 0 ] . picture [ i ] . substr ( 12 , res [ 0 ] . picture [ i ] . length - 12 ) ;
173
+ var pp = path . resolve ( __dirname , './../../../frontend/express/public/userimages/' + id ) ;
174
+ countlyFs . deleteFile ( "userimages" , pp , { id :id } , function ( err ) {
175
+ if ( err )
176
+ console . log ( err ) ;
177
+ } ) ;
178
+ }
172
179
}
173
180
try {
174
181
fs . appendFileSync ( path . resolve ( __dirname , './../../../log/deletedUsers' + app_id + '.txt' ) , res [ 0 ] . uid . join ( "\n" ) + "\n" , "utf-8" ) ;
0 commit comments