checkDataIntegrity

git-svn-id: svn://home0/checkDataIntegrity@3075 71dcc7fd-b1f2-4e5d-bb8e-274146e81173
This commit is contained in:
(no author)
2023-05-31 19:22:38 +00:00
parent 2490594a27
commit 99d9a8e412
3 changed files with 29 additions and 27 deletions

View File

@@ -81,38 +81,40 @@ public class Main {
.stream()
.parallel()
.forEach(p0 -> {
final long cnt = count.incrementAndGet();
if (cnt % 1000 == 0) {
System.out.println(cnt);
}
final String rel = p0.toString().substring(path0.length());
final Path p1 = Path.of(path1 + rel);
final byte[] buf0 = bufs0.get();
final byte[] buf1 = bufs1.get();
try (InputStream inputStream0 = new BufferedInputStream(new FileInputStream(p0.toFile()), 65536); InputStream inputStream1 = new BufferedInputStream(new FileInputStream(p1.toFile()), 65536)) {
int len0, len1;
do {
len0 = inputStream0.read(buf0);
len1 = inputStream1.read(buf1);
if (len0 != len1) {
System.out.println(rel + ": Length mismatch");
countErr.incrementAndGet();
break;
}
if (len0 > -1 && !Arrays.equals(buf0, 0, len0, buf1, 0, len1)) {
System.out.println(rel + ": Data mismatch");
countErr.incrementAndGet();
break;
}
} while (len0 > -1);
try {
final long cnt = count.incrementAndGet();
if (cnt % 1000 == 0) {
System.out.println(cnt);
}
final String rel = p0.toString().substring(path0.length());
final Path p1 = Path.of(path1 + rel);
final byte[] buf0 = bufs0.get();
final byte[] buf1 = bufs1.get();
try (InputStream inputStream0 = new BufferedInputStream(new FileInputStream(p0.toFile()), 65536); InputStream inputStream1 = new BufferedInputStream(new FileInputStream(p1.toFile()), 65536)) {
int len0, len1;
do {
len0 = inputStream0.read(buf0);
len1 = inputStream1.read(buf1);
if (len0 != len1) {
System.out.println(rel + ": Length mismatch");
countErr.incrementAndGet();
break;
}
if (len0 > -1 && !Arrays.equals(buf0, 0, len0, buf1, 0, len1)) {
System.out.println(rel + ": Data mismatch");
countErr.incrementAndGet();
break;
}
} while (len0 > -1);
}
}
catch (NoSuchFileException | FileNotFoundException | InvalidPathException ex) {
// System.out.println(rel + ": NoSuchFileException");
}
catch (final Exception ex) {
System.out.println(rel + ": Exception: " + ex.getClass().getName() + " " + ex.getMessage());
System.out.println(p0 + ": Exception: " + ex.getClass().getName() + " " + ex.getMessage());
countErr.incrementAndGet();
}
});