<commit_before>'use strict';

var async = require('async');

var config = require('../config/configuration.js');
var retrieveChanges = require('./helpers/retrieve.js');

module.exports = function updateAccount(serviceData, cursor, queues, cb) {
  // Retrieve all files since last call
  if(!serviceData.token) {
    return cb('token can\'t be ' + serviceData.token);
  }
  if(!cursor) {
    cursor = 0;
  }
  async.waterfall([
    function getChanges(cb) {
      retrieveChanges(cursor, serviceData.token, cb);
    },
    function applyChanges(newCursor, changes, cb) {
      if(!changes) {
        return cb(null, newCursor, serviceData);
      }
      changes.forEach(function(change) {
        if(change.deleted) {
          queues.deletion.push({
            title: change.title,
            identifier: change.guid
          });
        }
        else {
          queues.addition.push({
            title: change.title,
            url: config.evernoteRoot + '/Home.action#n=' + change.guid + "&ses=4&sh=2&sds=5",
            created: new Date(change.created),
            updated: new Date(change.updated),
            identifier: change.guid,
          });
        }
      });

      cb(null, newCursor, serviceData);
    }
  ], cb);
};<commit_msg>Don't send deletion on first update<commit_after>'use strict';

var async = require('async');

var config = require('../config/configuration.js');
var retrieveChanges = require('./helpers/retrieve.js');

module.exports = function updateAccount(serviceData, cursor, queues, cb) {
  // Retrieve all files since last call
  if(!serviceData.token) {
    return cb('token can\'t be ' + serviceData.token);
  }
  if(!cursor) {
    cursor = 0;
  }
  async.waterfall([
    function getChanges(cb) {
      retrieveChanges(cursor, serviceData.token, cb);
    },
    function applyChanges(newCursor, changes, cb) {
      if(!changes) {
        return cb(null, newCursor, serviceData);
      }
      changes.forEach(function(change) {
        if(change.deleted) {
          if(cursor) {
            queues.deletion.push({
              title: change.title,
              identifier: change.guid
            });
          }
        }
        else {
          queues.addition.push({
            title: change.title,
            url: config.evernoteRoot + '/Home.action#n=' + change.guid + "&ses=4&sh=2&sds=5",
            created: new Date(change.created),
            updated: new Date(change.updated),
            identifier: change.guid,
          });
        }
      });

      cb(null, newCursor, serviceData);
    }
  ], cb);
};
{'fraction_non_alphanumeric': 0.13941747572815533, 'fraction_numerical': 0.0031067961165048546, 'mean_word_length': 2.2240300375469335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1491340', 'n_tokens_mistral': 757, 'n_tokens_neox': 752, 'n_words': 156}