code: private Collection<String> getS3PrefixesForTask(S3Configuration s3Configuration, SingularityTaskId taskId, Optional<Long> startArg, Optional<Long> endArg, String group, SingularityUser user) {
      Optional<SingularityTaskHistory> history = getTaskHistory(taskId, user);
  
      long start = taskId.getStartedAt();
      if (startArg.isPresent()) {
        start = Math.max(startArg.get(), start);
      }
  
      long end = start + s3Configuration.getMissingTaskDefaultS3SearchPeriodMillis();
  
      if (history.isPresent()) {
        SimplifiedTaskState taskState = SingularityTaskHistoryUpdate.getCurrentState(history.get().getTaskUpdates());
  
        if (taskState == SimplifiedTaskState.DONE) {
          end = Iterables.getLast(history.get().getTaskUpdates()).getTimestamp();
        } else {
          end = System.currentTimeMillis();
        }
      }
  
      if (endArg.isPresent()) {
        end = Math.min(endArg.get(), end);
      }
  
      Optional<String> tag = Optional.absent();
      if (history.isPresent() && history.get().getTask().getTaskRequest().getDeploy().getExecutorData().isPresent()) {
        tag = history.get().getTask().getTaskRequest().getDeploy().getExecutorData().get().getLoggingTag();
      }
  
      Collection<String> prefixes = SingularityS3FormatHelper.getS3KeyPrefixes(s3Configuration.getS3KeyFormat(), taskId, tag, start, end, group);
      for (SingularityS3UploaderFile additionalFile : s3Configuration.getS3UploaderAdditionalFiles()) {
        if (additionalFile.getS3UploaderKeyPattern().isPresent() && !additionalFile.getS3UploaderKeyPattern().get().equals(s3Configuration.getS3KeyFormat())) {
          prefixes.addAll(SingularityS3FormatHelper.getS3KeyPrefixes(additionalFile.getS3UploaderKeyPattern().get(), taskId, tag, start, end, group));
        }
      }
  
      LOG.trace("Task {} got S3 prefixes {} for start {}, end {}, tag {}", taskId, prefixes, start, end, tag);
  
      return prefixes;
    }
docs: Generation of prefixes