<commit_before>'use strict';

const UploadedFile = require('../uploaded-file');
const logger = require('../logger');

// aliases
exports.download = require('./download');
exports.validate = require('./validate');
exports.uploadAndCopy = require('./upload');

// do all the things
exports.work = (audioEvent) => {
  let file = new UploadedFile(audioEvent);

  // process file - catch most errors
  return exports.download(audioEvent.audioUploadPath).then(data => {
    file.setDownloaded(data);
    return Q.all([
      exports.validate(file.localPath),
      exports.uploadAndCopy(file)
    ]);
  }).then(results => {
    file.setValidated(results[0]);
    file.setProcessed(results[1]);
    return file.callback().then(() => true);
  }).catch(err => {
    if (err.noRetry) {
      logger.warn(err.message);
      file.setError(err);
      return file.callback().then(() => false);
    } else {
      throw err; // will be retried by SNS
    }
  });
}
<commit_msg>More explicit logging<commit_after>'use strict';

const UploadedFile = require('../uploaded-file');
const logger = require('../logger');

// aliases
exports.download = require('./download');
exports.validate = require('./validate');
exports.uploadAndCopy = require('./upload');

// do all the things
exports.work = (audioEvent) => {
  let file = new UploadedFile(audioEvent);

  // process file - catch most errors
  return exports.download(audioEvent.audioUploadPath).then(data => {
    file.setDownloaded(data);
    return Q.all([
      exports.validate(file.localPath),
      exports.uploadAndCopy(file)
    ]);
  }).then(results => {
    file.setValidated(results[0]);
    file.setProcessed(results[1]);
    return file.callback().then(() => true);
  }).catch(err => {
    if (err.noRetry) {
      logger.warn(`NoRetry ${err.message}`);
      file.setError(err);
      return file.callback().then(() => false);
    } else {
      throw err; // will be retried by SNS
    }
  });
}

{'fraction_non_alphanumeric': 0.17496151872755258, 'fraction_numerical': 0.002052334530528476, 'mean_word_length': 3.3526785714285716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3181814', 'n_tokens_mistral': 591, 'n_tokens_neox': 592, 'n_words': 121}