/** * Verifies an MP3 Release * * @param release Release to verify */ public void checkSfv(Release release) { if (Thread.currentThread().isInterrupted()) { return; } if (!release.isReleaseComplete()) { release.setReleaseIsValid(false); return; } boolean isValid = true; for (AudioFileWithChecksum m : release.getAudioFiles()) { if (!m.getAudioFileExists()) { isValid = false; } else { try { if (m.getChecksum() == FileUtils.checksumCRC32(m.getAudioFile())) { m.setAudioFileIsValid(true); } else { m.setAudioFileIsValid(false); isValid = false; } } catch (IOException ex) { Logger.getLogger(CRCChecker.class.getName()).log(Level.SEVERE, null, ex); } } } release.setReleaseIsValid(isValid); }
@Override public void run() { actionFrame = new ActionFrame(mainWindow); actionFrame.setTitle("Verifying Releases..."); actionFrame.getProgressBar().setIndeterminate(false); actionFrame.getProgressBar().setMinimum(0); actionFrame.getProgressBar().setMaximum(toCheck.size()); actionFrame.getProgressBar().setValue(0); actionFrame.setVisible(true); time = System.currentTimeMillis() - 1; for (Release release : toCheck) { timeGone = System.currentTimeMillis() - time; actionFrame.setStatusLabelText( "Veryfied " + counter + " of " + toCheck.size() + " Releases (" + size / timeGone / 1024 + " MB/s)"); if (this.isInterrupted()) { actionFrame.setStatusLabelText("Verify aborted."); actionFrame.setOkButtonEnabled(true); return; } checkSfv(release); size += release.getSize(); counter++; actionFrame.getProgressBar().setValue(counter); if (release.isValid()) { countValid++; } else { countInvalid++; } } actionFrame.setStatusLabelText( countValid + " valid and " + countInvalid + " invalid Releases verfied (" + size / timeGone / 1024 + " MB/s)."); actionFrame.setAbortButtonEnabled(false); actionFrame.setOkButtonEnabled(true); }