Search in sources :

Example 1 with ArchiveInfo

use of org.haiku.haikudepotserver.support.ArchiveInfo in project haikudepotserver by haiku.

the class PkgDumpExportJobRunner method createArchiveInfo.

private ArchiveInfo createArchiveInfo(ObjectContext context, PkgDumpExportJobSpecification specification) {
    RepositorySource repositorySource = RepositorySource.tryGetByCode(context, specification.getRepositorySourceCode()).orElseThrow(() -> new IllegalStateException("unable to find the repository source [" + specification.getRepositorySourceCode() + "]"));
    Date modifyTimestamp = pkgService.getLastModifyTimestampSecondAccuracy(context, repositorySource);
    return new ArchiveInfo(DateTimeHelper.secondAccuracyDatePlusOneSecond(modifyTimestamp), runtimeInformationService.getProjectVersion());
}
Also used : ArchiveInfo(org.haiku.haikudepotserver.support.ArchiveInfo) Date(java.util.Date)

Example 2 with ArchiveInfo

use of org.haiku.haikudepotserver.support.ArchiveInfo in project haikudepotserver by haiku.

the class AbstractPkgResourceExportArchiveJobRunner method appendArchiveInfo.

/**
 * <p>Adds a little informational file into the tar-ball.</p>
 */
private void appendArchiveInfo(State state) throws IOException {
    ArchiveInfo archiveInfo = new ArchiveInfo(DateTimeHelper.secondAccuracyDatePlusOneSecond(state.latestModifiedTimestamp), runtimeInformationService.getProjectVersion());
    byte[] payload = objectMapper.writeValueAsBytes(archiveInfo);
    TarArchiveEntry tarEntry = new TarArchiveEntry(getPathComponentTop() + "/info.json");
    tarEntry.setSize(payload.length);
    tarEntry.setModTime(roundTimeToSecondPlusOne(state.latestModifiedTimestamp));
    state.tarArchiveOutputStream.putArchiveEntry(tarEntry);
    state.tarArchiveOutputStream.write(payload);
    state.tarArchiveOutputStream.closeArchiveEntry();
}
Also used : ArchiveInfo(org.haiku.haikudepotserver.support.ArchiveInfo) TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry)

Aggregations

ArchiveInfo (org.haiku.haikudepotserver.support.ArchiveInfo)2 Date (java.util.Date)1 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)1