Browse Source

Don't track the extracted files for removal on cancel.

master
Reece H. Dunn 9 years ago
parent
commit
01e8e5ad98
1 changed files with 0 additions and 16 deletions
  1. 0
    16
      android/src/com/reecedunn/espeak/DownloadVoiceData.java

+ 0
- 16
android/src/com/reecedunn/espeak/DownloadVoiceData.java View File

} }


private static class AsyncExtract extends AsyncTask<Void, Void, Integer> { private static class AsyncExtract extends AsyncTask<Void, Void, Integer> {
private final LinkedList<File> mExtractedFiles = new LinkedList<File>();

private final Context mContext; private final Context mContext;
private final int mRawResId; private final int mRawResId;
private final File mOutput; private final File mOutput;
while (!isCancelled() && ((entry = zipStream.getNextEntry()) != null)) { while (!isCancelled() && ((entry = zipStream.getNextEntry()) != null)) {
final File outputFile = new File(mOutput, entry.getName()); final File outputFile = new File(mOutput, entry.getName());


mExtractedFiles.add(outputFile);

if (entry.isDirectory()) { if (entry.isDirectory()) {
outputFile.mkdirs(); outputFile.mkdirs();
FileUtils.chmod(outputFile); FileUtils.chmod(outputFile);


final String version = FileUtils.read(mContext.getResources().openRawResource(R.raw.espeakdata_version)); final String version = FileUtils.read(mContext.getResources().openRawResource(R.raw.espeakdata_version));
final File outputFile = new File(mOutput, "espeak-data/version"); final File outputFile = new File(mOutput, "espeak-data/version");
mExtractedFiles.add(outputFile);


FileUtils.write(outputFile, version); FileUtils.write(outputFile, version);
successful = true; successful = true;
} }


if (isCancelled() || !successful) { if (isCancelled() || !successful) {
removeExtractedFiles();
return RESULT_CANCELED; return RESULT_CANCELED;
} }


return RESULT_OK; return RESULT_OK;
} }

private void removeExtractedFiles() {
for (File extractedFile : mExtractedFiles) {
if (!extractedFile.isDirectory()) {
extractedFile.delete();
}
}

mExtractedFiles.clear();
}
} }
} }

Loading…
Cancel
Save