private static List<File> resolveAndArchive(Configuration conf, FileSystem fs,
    Path baseArchiveDir, Collection<File> toArchive, long start) throws IOException {
    // Early exit if no files to archive
    if (toArchive.isEmpty()) {
      LOG.trace("No files to archive, returning an empty list.");
      return Collections.emptyList();
    }

    LOG.trace("Preparing to archive files into directory: {}", baseArchiveDir);

    // Ensure the archive directory exists
    ensureArchiveDirectoryExists(fs, baseArchiveDir);

    // Thread-safe collection for storing failures
    Queue<File> failures = new ConcurrentLinkedQueue<>();
    String startTime = Long.toString(start);

    // Separate files and directories for processing
    List<File> filesOnly = new ArrayList<>();
    for (File file : toArchive) {
      if (file.isFile()) {
        filesOnly.add(file);
      } else {
        handleDirectory(conf, fs, baseArchiveDir, failures, file, start);
      }
    }

    // Archive files concurrently
    archiveFilesConcurrently(conf, baseArchiveDir, filesOnly, failures, startTime);

    return new ArrayList<>(failures); // Convert to a List for the return value
  }
Resolve any conflict with an existing archive file via timestamp-append renaming of the
existing file and then archive the passed in files.
@param fs             {@link FileSystem} on which to archive the files
@param baseArchiveDir base archive directory to store the files. If any of the files to archive
                      are directories, will append the name of the directory to the base
                      archive directory name, creating a parallel structure.
@param toArchive      files/directories that need to be archvied
@param start          time the archiving started - used for resolving archive conflicts.
@return the list of failed to archive files.
@throws IOException if an unexpected file operation exception occurred
hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java