Ignore errors that are likely due to filesystem corruption.
There is a specific POSIX error "EIO" which seems to be the "general purpose we don't know what went wrong but its probably bad" exception. Our investigations in #855 resulted in the conclusion that it is likely due to some sort of filesystem corruption or something like that. Either way, it is annoying many people, so we need to prevent it or ignore it, rather than prompting the user to submit a bug report. After much investigation it was unable to be reproduced other than by one of the original bug reporters. As such, this change ignores it. Unfortunately Java `IOException`s don't have an API for getting the errno of a POSIX IO error. Thus, this change results to parsing the exception message instead :( Fixes #855.
This commit is contained in:
parent
42fa371e1b
commit
dacebceff6
@ -417,13 +417,29 @@ public final class Utils {
|
||||
|
||||
byte[] mdbytes = md.digest();
|
||||
return toHexString(mdbytes).toLowerCase(Locale.ENGLISH);
|
||||
} catch (IOException | NoSuchAlgorithmException e) {
|
||||
} catch (IOException e) {
|
||||
// The annoyance (potentially) caused by miscellaneous filesystem corruption results in
|
||||
// F-Droid constantly popping up crash reports when F-Droid isn't even open. As such this
|
||||
// exception-message-parsing-and-throwing-a-new-ignorable-exception-hackery is probably
|
||||
// warranted. See https://www.gitlab.com/fdroid/fdroidclient/issues/855 for more detail.
|
||||
if (e.getMessage().contains("read failed: EIO (I/O error)")) {
|
||||
throw new PotentialFilesystemCorruptionException(e);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
} finally {
|
||||
closeQuietly(fis);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PotentialFilesystemCorruptionException extends IllegalArgumentException {
|
||||
public PotentialFilesystemCorruptionException(IOException e) {
|
||||
super(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the base 16 representation of the byte array argument.
|
||||
*
|
||||
|
@ -249,6 +249,13 @@ public class InstalledAppProviderService extends IntentService {
|
||||
}
|
||||
|
||||
insertAppIntoDb(this, packageInfo, hashType, hash);
|
||||
} catch (Utils.PotentialFilesystemCorruptionException e) {
|
||||
Log.e(TAG, "Encountered potential filesystem corruption, or other unknown " +
|
||||
"problem when calculating hash of " + apk.getAbsolutePath() + ". " +
|
||||
"It is unlikely F-Droid can do anything about this, and this " +
|
||||
"likely happened in the background. As such, we will continue without " +
|
||||
"interrupting the user by asking them to send a crash report.");
|
||||
return;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Utils.debugLog(TAG, e.getMessage());
|
||||
ACRA.getErrorReporter().handleException(e, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user