mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-20 04:41:52 -05:00
Added exception for empty files
This commit is contained in:
parent
9843bafafd
commit
f484122c35
@ -33,7 +33,14 @@ import org.sufficientlysecure.keychain.util.PositionAwareInputStream;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v4.content.AsyncTaskLoader;
|
import android.support.v4.content.AsyncTaskLoader;
|
||||||
|
|
||||||
|
import com.devspark.appmsg.AppMsg;
|
||||||
|
|
||||||
public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||||
|
|
||||||
|
public static class FileHasNoContent extends Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
|
||||||
InputData mInputData;
|
InputData mInputData;
|
||||||
@ -92,6 +99,9 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private void generateListOfKeyrings(InputData inputData) {
|
private void generateListOfKeyrings(InputData inputData) {
|
||||||
|
|
||||||
|
boolean isEmpty = true;
|
||||||
|
|
||||||
PositionAwareInputStream progressIn = new PositionAwareInputStream(
|
PositionAwareInputStream progressIn = new PositionAwareInputStream(
|
||||||
inputData.getInputStream());
|
inputData.getInputStream());
|
||||||
|
|
||||||
@ -103,6 +113,7 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
|||||||
|
|
||||||
// read all available blocks... (asc files can contain many blocks with BEGIN END)
|
// read all available blocks... (asc files can contain many blocks with BEGIN END)
|
||||||
while (bufferedInput.available() > 0) {
|
while (bufferedInput.available() > 0) {
|
||||||
|
isEmpty = false;
|
||||||
InputStream in = PGPUtil.getDecoderStream(bufferedInput);
|
InputStream in = PGPUtil.getDecoderStream(bufferedInput);
|
||||||
PGPObjectFactory objectFactory = new PGPObjectFactory(in);
|
PGPObjectFactory objectFactory = new PGPObjectFactory(in);
|
||||||
|
|
||||||
@ -120,7 +131,12 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(Constants.TAG, "Exception on parsing key file!", e);
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isEmpty) {
|
||||||
|
Log.e(Constants.TAG, "File has no content!", new FileHasNoContent());
|
||||||
|
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(data, new FileHasNoContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user