function storeOldFile(task, step) {
  return new Promise(function (resolve, reject) {
    var gfs = Grid(mongoose.connection.db);
    var options = xcode(step.options, true);

    gfs.findOne(options, function (err, file) {
      if (err) return reject(err);
      if (!file) return resolve(false);

      var collection = task.constructor.collection;
      step.dataStore = [{removed: file._id, shadow: dbUtils.generateId()}];

      collection.updateOne({_id: task._id}, task.toObject()).then(function(){
        var writeStream = gfs.createWriteStream({
          _id: step.dataStore[0].shadow,
          metadata: {oldFile: file}
        });

        writeStream.on("close", resolve);
        writeStream.on("error", reject);

        gfs.createReadStream({_id: file._id}).pipe(writeStream);
      });
    });
  });
}
This function stores a file that's about to be
removed by a step, for rollback purposes

@param task the task
@param step the step

@returns {Promise|*}