@@ -285,48 +285,43 @@ class Database {
285
285
}
286
286
287
287
checkDuplicate ( file , callback ) {
288
- try {
289
- let header = Parser . getHeader ( file ) ;
288
+ let header = Parser . getHeader ( file ) ;
290
289
291
- if ( header . err ) {
292
- callback ( header . err ) ;
293
- return ;
294
- }
290
+ if ( header . err ) {
291
+ callback ( header . err ) ;
292
+ return ;
293
+ }
295
294
296
- let search = { } ;
295
+ let search = { } ;
297
296
298
- // duplicate criteria:
299
- // same type
300
- search . type = header . type ;
297
+ // duplicate criteria:
298
+ // same type
299
+ search . type = header . type ;
301
300
302
- //search.loopLength = data.header.m_elapsedGameLoops;
303
-
304
- // same map
305
- search . map = header . map ;
306
-
307
- // same players
308
- // they should be in identical order but just in case
309
- search . $and = [ ] ;
310
- for ( let p of header . playerIDs ) {
311
- search . $and . push ( { playerIDs : p } ) ;
312
- }
301
+ //search.loopLength = data.header.m_elapsedGameLoops;
302
+
303
+ // same map
304
+ search . map = header . map ;
313
305
314
- // date within 1 minute
315
- let dateMin = new Date ( header . date . getTime ( ) - 60000 ) ;
316
- let dateMax = new Date ( header . date . getTime ( ) + 60000 ) ;
317
- search . $where = function ( ) {
318
- let d = new Date ( this . date ) ;
319
- return dateMin <= d && d <= dateMax ;
320
- }
321
-
322
- // this is the one raw call that is not preprocessed by collections for what should be somewhat obvious reasons
323
- this . _db . matches . find ( search , function ( err , docs ) {
324
- callback ( docs . length > 0 ) ;
325
- } ) ;
306
+ // same players
307
+ // they should be in identical order but just in case
308
+ search . $and = [ ] ;
309
+ for ( let p of header . playerIDs ) {
310
+ search . $and . push ( { playerIDs : p } ) ;
326
311
}
327
- catch ( err ) {
328
- callback ( 'Internal Exception' ) ;
312
+
313
+ // date within 1 minute
314
+ let dateMin = new Date ( header . date . getTime ( ) - 60000 ) ;
315
+ let dateMax = new Date ( header . date . getTime ( ) + 60000 ) ;
316
+ search . $where = function ( ) {
317
+ let d = new Date ( this . date ) ;
318
+ return dateMin <= d && d <= dateMax ;
329
319
}
320
+
321
+ // this is the one raw call that is not preprocessed by collections for what should be somewhat obvious reasons
322
+ this . _db . matches . find ( search , function ( err , docs ) {
323
+ callback ( docs . length > 0 ) ;
324
+ } ) ;
330
325
}
331
326
332
327
// counts the given matches
0 commit comments