<commit_before>const fs = require('fs');

module.exports = function (data) {
  return {
    getPhotoUpload(req, res) {
      if (!req.user) {
        return res.redirect('/');
      }

      res.render('upload', {
        title: 'Photo Upload'
      });
    },
    postPhotoUpload(req, res) {
      if (!req.user) {
        return res.redirect('/');
      }

      const photoDestination = req.file.path;

      data.createPhoto(fs.readFileSync(photoDestination), req.file.mimetype, req.user.email)
      .then((photo) => {
        fs.unlinkSync(photoDestination);

        req.flash('success', {
          msg: 'File was uploaded successfully.'
        });

        res.redirect('/upload');
      });
    }
  };
};
<commit_msg>Redirect to photo details when upload<commit_after>const fs = require('fs');

module.exports = function (data) {
  return {
    getPhotoUpload(req, res) {
      if (!req.user) {
        return res.redirect('/');
      }

      res.render('upload', {
        title: 'Photo Upload'
      });
    },
    postPhotoUpload(req, res) {
      if (!req.user) {
        return res.redirect('/');
      }

      const photoDestination = req.file.path;

      data.createPhoto(fs.readFileSync(photoDestination), req.file.mimetype, req.user.email)
      .then((photo) => {
        fs.unlinkSync(photoDestination);

        req.flash('success', {
          msg: 'Your photo was uploaded successfully.'
        });

        res.redirect(`/photo/details/${photo._id}`);
      });
    }
  };
};

{'fraction_non_alphanumeric': 0.16069057104913678, 'fraction_numerical': 0.0, 'mean_word_length': 2.1527196652719667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3808192', 'n_tokens_mistral': 467, 'n_tokens_neox': 462, 'n_words': 82}