createInsertStream = async (slimEntries, storage) => {
  let insertIndex = 0

  const insertMedia = (ctx, date, cb) => {
    const next = () => {
      if (insertIndex >= slimEntries.length || slimEntries[insertIndex].date < date) {
        return cb()
      }

      const slimEntry = slimEntries[insertIndex++]
      storage.readMediaCache(slimEntry, (err, entry) => {
        if (err) {
          log.warn(err, `Failed to read media cache for slim entry ${slimEntry}. Skip it`)
          return next()
        }
        ctx.push(entry)
        next()
      })
    }

    next()
  }

  return through(function(media, enc, cb) {
    if (insertIndex >= slimEntries.length) {
      // all files have been inserted already
      return cb(null, media)
    }

    // insert entries until media date
    insertMedia(this, media.date, () => {
      cb(null, media)
    })
  }, function(cb) {
    // insert remaining entries
    insertMedia(this, '0000-00-00', () => {
      storage.clearCache()
      cb()
    })
  })
}
@param {object} slimEntries
@param {import('../storage.js').Storage} storage
@returns