Log reason for ignoring pack when IOException occurred
This should help to identify the root cause of the problem discussed on the Gerrit list [1]. [1] https://groups.google.com/forum/#!topic/repo-discuss/Qdmbl-YZ4NU Change-Id: I871f70e4bb1227952e1544b789013583b14e2b96 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
741ebca8b7
commit
9b86ebb4f6
|
@ -207,6 +207,7 @@ exceptionCaughtDuringExecutionOfRmCommand=Exception caught during execution of r
|
|||
exceptionCaughtDuringExecutionOfTagCommand=Exception caught during execution of tag command
|
||||
exceptionOccurredDuringAddingOfOptionToALogCommand=Exception occurred during adding of {0} as option to a Log command
|
||||
exceptionOccurredDuringReadingOfGIT_DIR=Exception occurred during reading of $GIT_DIR/{0}. {1}
|
||||
exceptionWhileReadingPack=ERROR: Exception caught while accessing pack file {0}, the pack file might be corrupt
|
||||
expectedACKNAKFoundEOF=Expected ACK/NAK, found EOF
|
||||
expectedACKNAKGot=Expected ACK/NAK, got: {0}
|
||||
expectedBooleanStringValue=Expected boolean string value
|
||||
|
|
|
@ -266,6 +266,7 @@ public static JGitText get() {
|
|||
/***/ public String exceptionCaughtDuringExecutionOfTagCommand;
|
||||
/***/ public String exceptionOccurredDuringAddingOfOptionToALogCommand;
|
||||
/***/ public String exceptionOccurredDuringReadingOfGIT_DIR;
|
||||
/***/ public String exceptionWhileReadingPack;
|
||||
/***/ public String expectedACKNAKFoundEOF;
|
||||
/***/ public String expectedACKNAKGot;
|
||||
/***/ public String expectedBooleanStringValue;
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -329,7 +331,7 @@ void resolve(Set<ObjectId> matches, AbbreviatedObjectId id)
|
|||
p.resolve(matches, id, RESOLVE_ABBREV_LIMIT);
|
||||
} catch (IOException e) {
|
||||
// Assume the pack is corrupted.
|
||||
//
|
||||
logCorruptPackError(e, p);
|
||||
removePack(p);
|
||||
}
|
||||
if (matches.size() > RESOLVE_ABBREV_LIMIT)
|
||||
|
@ -418,6 +420,7 @@ ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId) {
|
|||
continue SEARCH;
|
||||
} catch (IOException e) {
|
||||
// Assume the pack is corrupted.
|
||||
logCorruptPackError(e, p);
|
||||
removePack(p);
|
||||
}
|
||||
}
|
||||
|
@ -499,6 +502,7 @@ private long getPackedObjectSize(WindowCursor curs, AnyObjectId id) {
|
|||
continue SEARCH;
|
||||
} catch (IOException e) {
|
||||
// Assume the pack is corrupted.
|
||||
logCorruptPackError(e, p);
|
||||
removePack(p);
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +545,7 @@ void selectObjectRepresentation(PackWriter packer, ObjectToPack otp,
|
|||
continue SEARCH;
|
||||
} catch (IOException e) {
|
||||
// Assume the pack is corrupted.
|
||||
//
|
||||
logCorruptPackError(e, p);
|
||||
removePack(p);
|
||||
}
|
||||
}
|
||||
|
@ -552,6 +556,18 @@ void selectObjectRepresentation(PackWriter packer, ObjectToPack otp,
|
|||
h.db.selectObjectRepresentation(packer, otp, curs);
|
||||
}
|
||||
|
||||
private static void logCorruptPackError(IOException e, PackFile p) {
|
||||
StringBuilder buf = new StringBuilder(MessageFormat.format(
|
||||
JGitText.get().exceptionWhileReadingPack,
|
||||
p.getPackFile().getAbsolutePath()));
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw));
|
||||
buf.append('\n');
|
||||
buf.append(sw.toString());
|
||||
// TODO instead of syserr we should use a logging framework
|
||||
System.err.println(buf.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
InsertLooseObjectResult insertUnpackedObject(File tmp, ObjectId id,
|
||||
boolean createDuplicate) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue