Search in sources :

Example 1 with ChecksumAlgorithm

use of org.apache.archiva.checksum.ChecksumAlgorithm in project archiva by apache.

the class AbstractTransactionEvent method createChecksums.

/**
 * Create checksums of file using all digesters defined at construction time.
 *
 * @param file
 * @param force whether existing checksums should be overwritten or not
 * @throws IOException
 */
protected void createChecksums(Path file, boolean force) throws IOException {
    for (ChecksumAlgorithm checksumAlgorithm : getChecksumAlgorithms()) {
        Path checksumFile = Paths.get(file.toAbsolutePath() + "." + getChecksumFileExtension(checksumAlgorithm));
        if (Files.exists(checksumFile)) {
            if (!force) {
                continue;
            }
            createBackup(checksumFile);
        } else {
            createdFiles.add(checksumFile);
        }
    }
    ChecksummedFile csFile = new ChecksummedFile(file);
    csFile.fixChecksums(getChecksumAlgorithms());
}
Also used : Path(java.nio.file.Path) ChecksumAlgorithm(org.apache.archiva.checksum.ChecksumAlgorithm) ChecksummedFile(org.apache.archiva.checksum.ChecksummedFile)

Aggregations

Path (java.nio.file.Path)1 ChecksumAlgorithm (org.apache.archiva.checksum.ChecksumAlgorithm)1 ChecksummedFile (org.apache.archiva.checksum.ChecksummedFile)1