Merge changes I368af61a,I2400fe5f

* changes:
  Remove pack from list when file handle is stale
  Lower log level to warn for handled pack errors
This commit is contained in:
Matthias Sohn 2015-04-30 10:43:46 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 7e0ebb8e29
3 changed files with 23 additions and 6 deletions

View File

@ -394,6 +394,7 @@ packfileCorruptionDetected=Packfile corruption detected: {0}
packFileInvalid=Pack file invalid: {0}
packfileIsTruncated=Packfile {0} is truncated.
packfileIsTruncatedNoParam=Packfile is truncated.
packHandleIsStale=Pack file {0} handle is stale, removing it from pack list
packHasUnresolvedDeltas=pack has unresolved deltas
packingCancelledDuringObjectsWriting=Packing cancelled during objects writing
packObjectCountMismatch=Pack object count mismatch: pack {0} index {1}: {2}

View File

@ -453,6 +453,7 @@ public static JGitText get() {
/***/ public String packFileInvalid;
/***/ public String packfileIsTruncated;
/***/ public String packfileIsTruncatedNoParam;
/***/ public String packHandleIsStale;
/***/ public String packHasUnresolvedDeltas;
/***/ public String packingCancelledDuringObjectsWriting;
/***/ public String packObjectCountMismatch;

View File

@ -114,6 +114,8 @@ public class ObjectDirectory extends FileObjectDatabase {
/** Maximum number of candidates offered as resolutions of abbreviation. */
private static final int RESOLVE_ABBREV_LIMIT = 256;
private static final String STALE_FILE_HANDLE_MSG = "stale file handle"; //$NON-NLS-1$
private final Config config;
private final File objects;
@ -554,22 +556,35 @@ void selectObjectRepresentation(PackWriter packer, ObjectToPack otp,
}
private void handlePackError(IOException e, PackFile p) {
String tmpl;
String warnTmpl = null;
if ((e instanceof CorruptObjectException)
|| (e instanceof PackInvalidException)) {
tmpl = JGitText.get().corruptPack;
warnTmpl = JGitText.get().corruptPack;
// Assume the pack is corrupted, and remove it from the list.
removePack(p);
} else if (e instanceof FileNotFoundException) {
tmpl = JGitText.get().packWasDeleted;
warnTmpl = JGitText.get().packWasDeleted;
removePack(p);
} else if (e.getMessage() != null
&& e.getMessage().toLowerCase().contains(STALE_FILE_HANDLE_MSG)) {
warnTmpl = JGitText.get().packHandleIsStale;
removePack(p);
}
if (warnTmpl != null) {
if (LOG.isDebugEnabled()) {
LOG.debug(MessageFormat.format(warnTmpl,
p.getPackFile().getAbsolutePath()), e);
} else {
LOG.warn(MessageFormat.format(warnTmpl,
p.getPackFile().getAbsolutePath()));
}
} else {
tmpl = JGitText.get().exceptionWhileReadingPack;
// Don't remove the pack from the list, as the error may be
// transient.
LOG.error(MessageFormat.format(
JGitText.get().exceptionWhileReadingPack, p.getPackFile()
.getAbsolutePath()), e);
}
LOG.error(MessageFormat.format(tmpl,
p.getPackFile().getAbsolutePath()), e);
}
@Override