Merge "Add public isStaleFileHandle() API, improve detection."
This commit is contained in:
commit
cc50ec2d87
|
@ -114,8 +114,6 @@ 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;
|
||||
|
@ -565,8 +563,7 @@ private void handlePackError(IOException e, PackFile p) {
|
|||
} else if (e instanceof FileNotFoundException) {
|
||||
warnTmpl = JGitText.get().packWasDeleted;
|
||||
removePack(p);
|
||||
} else if (e.getMessage() != null
|
||||
&& e.getMessage().toLowerCase().contains(STALE_FILE_HANDLE_MSG)) {
|
||||
} else if (FileUtils.isStaleFileHandle(e)) {
|
||||
warnTmpl = JGitText.get().packHandleIsStale;
|
||||
removePack(p);
|
||||
}
|
||||
|
|
|
@ -514,4 +514,15 @@ else if (!ignoreCase
|
|||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an IOException is a Stale NFS File Handle
|
||||
*
|
||||
* @param ioe
|
||||
* @return a boolean true if the IOException is a Stale NFS FIle Handle
|
||||
*/
|
||||
public static boolean isStaleFileHandle(IOException ioe) {
|
||||
String msg = ioe.getMessage();
|
||||
return msg != null && msg.toLowerCase().matches("stale .*file .*handle");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue