|
|
@@ -66,6 +66,8 @@ import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
|
|
|
import org.eclipse.jgit.errors.CorruptObjectException; |
|
|
|
import org.eclipse.jgit.errors.PackInvalidException; |
|
|
|
import org.eclipse.jgit.errors.PackMismatchException; |
|
|
|
import org.eclipse.jgit.internal.JGitText; |
|
|
|
import org.eclipse.jgit.internal.storage.pack.ObjectToPack; |
|
|
@@ -330,9 +332,7 @@ public class ObjectDirectory extends FileObjectDatabase { |
|
|
|
try { |
|
|
|
p.resolve(matches, id, RESOLVE_ABBREV_LIMIT); |
|
|
|
} catch (IOException e) { |
|
|
|
// Assume the pack is corrupted. |
|
|
|
logCorruptPackError(e, p); |
|
|
|
removePack(p); |
|
|
|
handlePackError(e, p); |
|
|
|
} |
|
|
|
if (matches.size() > RESOLVE_ABBREV_LIMIT) |
|
|
|
return; |
|
|
@@ -419,9 +419,7 @@ public class ObjectDirectory extends FileObjectDatabase { |
|
|
|
if (searchPacksAgain(pList)) |
|
|
|
continue SEARCH; |
|
|
|
} catch (IOException e) { |
|
|
|
// Assume the pack is corrupted. |
|
|
|
logCorruptPackError(e, p); |
|
|
|
removePack(p); |
|
|
|
handlePackError(e, p); |
|
|
|
} |
|
|
|
} |
|
|
|
break SEARCH; |
|
|
@@ -501,9 +499,7 @@ public class ObjectDirectory extends FileObjectDatabase { |
|
|
|
if (searchPacksAgain(pList)) |
|
|
|
continue SEARCH; |
|
|
|
} catch (IOException e) { |
|
|
|
// Assume the pack is corrupted. |
|
|
|
logCorruptPackError(e, p); |
|
|
|
removePack(p); |
|
|
|
handlePackError(e, p); |
|
|
|
} |
|
|
|
} |
|
|
|
break SEARCH; |
|
|
@@ -544,9 +540,7 @@ public class ObjectDirectory extends FileObjectDatabase { |
|
|
|
pList = scanPacks(pList); |
|
|
|
continue SEARCH; |
|
|
|
} catch (IOException e) { |
|
|
|
// Assume the pack is corrupted. |
|
|
|
logCorruptPackError(e, p); |
|
|
|
removePack(p); |
|
|
|
handlePackError(e, p); |
|
|
|
} |
|
|
|
} |
|
|
|
break SEARCH; |
|
|
@@ -556,9 +550,19 @@ public class ObjectDirectory extends FileObjectDatabase { |
|
|
|
h.db.selectObjectRepresentation(packer, otp, curs); |
|
|
|
} |
|
|
|
|
|
|
|
private static void logCorruptPackError(IOException e, PackFile p) { |
|
|
|
StringBuilder buf = new StringBuilder(MessageFormat.format( |
|
|
|
JGitText.get().exceptionWhileReadingPack, |
|
|
|
private void handlePackError(IOException e, PackFile p) { |
|
|
|
String tmpl; |
|
|
|
if ((e instanceof CorruptObjectException) |
|
|
|
|| (e instanceof PackInvalidException)) { |
|
|
|
tmpl = JGitText.get().corruptPack; |
|
|
|
// Assume the pack is corrupted, and remove it from the list. |
|
|
|
removePack(p); |
|
|
|
} else { |
|
|
|
tmpl = JGitText.get().exceptionWhileReadingPack; |
|
|
|
// Don't remove the pack from the list, as the error may be |
|
|
|
// transient. |
|
|
|
} |
|
|
|
StringBuilder buf = new StringBuilder(MessageFormat.format(tmpl, |
|
|
|
p.getPackFile().getAbsolutePath())); |
|
|
|
StringWriter sw = new StringWriter(); |
|
|
|
e.printStackTrace(new PrintWriter(sw)); |