/** * Verify the integrity and connectivity of all objects in the object * database. * * @param pm * callback to provide progress feedback during the check. * @return all errors about the repository. * @throws java.io.IOException * if encounters IO errors during the process. */ public FsckError check(ProgressMonitor pm) throws IOException { if (pm == null) { pm = NullProgressMonitor.INSTANCE; } FsckError errors = new FsckError(); if (!connectivityOnly) { objChecker.reset(); checkPacks(pm, errors); } checkConnectivity(pm, errors); return errors; }
private void checkPacks(ProgressMonitor pm, FsckError errors) throws IOException, FileNotFoundException { try (DfsReader ctx = objdb.newReader()) { for (DfsPackFile pack : objdb.getPacks()) { DfsPackDescription packDesc = pack.getPackDescription(); if (packDesc.getPackSource() == PackSource.UNREACHABLE_GARBAGE) { continue; } try (ReadableChannel rc = objdb.openFile(packDesc, PACK)) { verifyPack(pm, errors, ctx, pack, rc); } catch (MissingObjectException e) { errors.getMissingObjects().add(e.getObjectId()); } catch (CorruptPackIndexException e) { errors.getCorruptIndices().add(new CorruptIndex( pack.getPackDescription().getFileName(INDEX), e.getErrorType())); } } } checkGitModules(pm, errors); }
private void verifyPack(ProgressMonitor pm, FsckError errors, DfsReader ctx, DfsPackFile pack, ReadableChannel ch) throws IOException, CorruptPackIndexException { FsckPackParser fpp = new FsckPackParser(objdb, ch); fpp.setObjectChecker(objChecker); fpp.overwriteObjectCount(pack.getPackDescription().getObjectCount()); fpp.parse(pm); errors.getCorruptObjects().addAll(fpp.getCorruptObjects()); fpp.verifyIndex(pack.getPackIndex(ctx)); }
&& tip.getType() != Constants.OBJ_COMMIT) { errors.getNonCommitHeads().add(r.getLeaf().getName()); errors.getMissingObjects().add(e.getObjectId()); continue; ow.checkConnectivity(); } catch (MissingObjectException e) { errors.getMissingObjects().add(e.getObjectId());
&& tip.getType() != Constants.OBJ_COMMIT) { errors.getNonCommitHeads().add(r.getLeaf().getName()); errors.getMissingObjects().add(e.getObjectId()); continue; ow.checkConnectivity(); } catch (MissingObjectException e) { errors.getMissingObjects().add(e.getObjectId());
private void checkPacks(ProgressMonitor pm, FsckError errors) throws IOException, FileNotFoundException { try (DfsReader ctx = objdb.newReader()) { for (DfsPackFile pack : objdb.getPacks()) { DfsPackDescription packDesc = pack.getPackDescription(); if (packDesc.getPackSource() == PackSource.UNREACHABLE_GARBAGE) { continue; } try (ReadableChannel rc = objdb.openFile(packDesc, PACK)) { verifyPack(pm, errors, ctx, pack, rc); } catch (MissingObjectException e) { errors.getMissingObjects().add(e.getObjectId()); } catch (CorruptPackIndexException e) { errors.getCorruptIndices().add(new CorruptIndex( pack.getPackDescription().getFileName(INDEX), e.getErrorType())); } } } checkGitModules(pm, errors); }
private void checkGitModules(ProgressMonitor pm, FsckError errors) throws IOException { pm.beginTask(JGitText.get().validatingGitModules, objChecker.getGitsubmodules().size()); for (GitmoduleEntry entry : objChecker.getGitsubmodules()) { AnyObjectId blobId = entry.getBlobId(); ObjectLoader blob = objdb.open(blobId, Constants.OBJ_BLOB); try { SubmoduleValidator.assertValidGitModulesFile( new String(blob.getBytes(), UTF_8)); } catch (SubmoduleValidationException e) { CorruptObject co = new FsckError.CorruptObject( blobId.toObjectId(), Constants.OBJ_BLOB, e.getFsckMessageId()); errors.getCorruptObjects().add(co); } pm.update(1); } pm.endTask(); }
/** * Verify the integrity and connectivity of all objects in the object * database. * * @param pm * callback to provide progress feedback during the check. * @return all errors about the repository. * @throws java.io.IOException * if encounters IO errors during the process. */ public FsckError check(ProgressMonitor pm) throws IOException { if (pm == null) { pm = NullProgressMonitor.INSTANCE; } FsckError errors = new FsckError(); if (!connectivityOnly) { objChecker.reset(); checkPacks(pm, errors); } checkConnectivity(pm, errors); return errors; }
private void verifyPack(ProgressMonitor pm, FsckError errors, DfsReader ctx, DfsPackFile pack, ReadableChannel ch) throws IOException, CorruptPackIndexException { FsckPackParser fpp = new FsckPackParser(objdb, ch); fpp.setObjectChecker(objChecker); fpp.overwriteObjectCount(pack.getPackDescription().getObjectCount()); fpp.parse(pm); errors.getCorruptObjects().addAll(fpp.getCorruptObjects()); fpp.verifyIndex(pack.getPackIndex(ctx)); }
private void checkGitModules(ProgressMonitor pm, FsckError errors) throws IOException { pm.beginTask(JGitText.get().validatingGitModules, objChecker.getGitsubmodules().size()); for (GitmoduleEntry entry : objChecker.getGitsubmodules()) { AnyObjectId blobId = entry.getBlobId(); ObjectLoader blob = objdb.open(blobId, Constants.OBJ_BLOB); try { SubmoduleValidator.assertValidGitModulesFile( new String(blob.getBytes(), UTF_8)); } catch (SubmoduleValidationException e) { CorruptObject co = new FsckError.CorruptObject( blobId.toObjectId(), Constants.OBJ_BLOB, e.getFsckMessageId()); errors.getCorruptObjects().add(co); } pm.update(1); } pm.endTask(); }