private void checkChecksums(CompressionProperties properties) throws IOException { out.println("Validating checksums."); File logdata = new File(targetFile, logProperties.getVariableDataFile()); if (!properties.getDataChecksum().equals(Files.hash(logdata, Hashing.sha1()).toString())) { throw new IOException("Variable data does not match with pre-compression data. Expect an unloadable data file."); } File index = new File(targetFile, logProperties.getVariablesIndexFile()); if (!properties.getTimestampChecksum().equals(Files.hash(index, Hashing.sha1()).toString())) { throw new IOException("Timestamp data does not match with pre-compression data. A bug has been found in the LogFileDecompressor and fixing it will make this data file readable again."); } out.println("Checksums validated."); }
private void setChecksums(CompressionProperties properties) throws IOException { out.println("Saving checksums to file"); File logdata = new File(logDirectory, logProperties.getVariableDataFile()); properties.setDataChecksum(Files.hash(logdata, Hashing.sha1()).toString()); File index = new File(logDirectory, logProperties.getVariablesIndexFile()); properties.setTimestampChecksum(Files.hash(index, Hashing.sha1()).toString()); out.println("Saved checksums"); }
File index = new File(logDirectory, logProperties.getVariablesIndexFile()); if (!index.exists()) throw new RuntimeException("Cannot find " + logProperties.getVariablesIndexFile());
File index = new File(logDirectory, logProperties.getVariablesIndexFile()); if (!index.exists()) throw new RuntimeException("Cannot find " + logProperties.getVariablesIndexFile());
properties.setTimestampedIndex(true); File compressedData = new File(directory, properties.getVariableDataFile()); File indexData = new File(directory, properties.getVariablesIndexFile());
outputChannel = outputStream.getChannel(); FileOutputStream indexStream = new FileOutputStream(new File(targetFile, logProperties.getVariablesIndexFile())); indexChannel = indexStream.getChannel();
FileChannel outputChannel = fileOutputStream.getChannel(); File indexFile = new File(destination, logProperties.getVariablesIndexFile()); FileOutputStream indexStream = new FileOutputStream(indexFile); FileChannel indexChannel = indexStream.getChannel();