001package org.kuali.common.devops.archive.sas; 002 003import static java.nio.file.Files.isDirectory; 004 005import java.nio.file.Path; 006 007import com.google.common.base.Function; 008 009public enum FileWeigher implements Function<Path, Double> { 010 INSTANCE; 011 012 @Override 013 public Double apply(Path file) { 014 if (isDirectory(file)) { 015 // Directories get a constant weight of one 016 // No bytes to transfer across the network, but we do have to create an S3 entry 017 return 1D; 018 } else { 019 // Otherwise the size of the file becomes it's weight 020 return file.toFile().length() * 1D; 021 } 022 } 023 024}