mirror of
https://github.com/jamessanford/kegs.git
synced 2025-01-07 22:32:56 +00:00
Move sync() to a different spot yet again.
This commit is contained in:
parent
8a977116c2
commit
52ca82acf1
@ -263,7 +263,7 @@ void android_config_init(char *output, int maxlen) {
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_froop_app_kegs_DiskLoader_nativeSync( JNIEnv* env, jobject thiz) {
|
||||
Java_com_froop_app_kegs_CopyHelper_nativeSync( JNIEnv* env, jobject thiz) {
|
||||
sync();
|
||||
sync();
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ public class CopyHelper {
|
||||
if (mPreface != null) {
|
||||
out.write(mPreface, 0, mPreface.length);
|
||||
}
|
||||
int totalread = 0;
|
||||
do {
|
||||
int numread = mInput.read(buf);
|
||||
if (numread <= 0) {
|
||||
@ -61,11 +62,18 @@ public class CopyHelper {
|
||||
} else {
|
||||
out.write(buf, 0, numread);
|
||||
}
|
||||
totalread += numread;
|
||||
} while (true);
|
||||
out.close();
|
||||
if (totalread > 400 * 1024) {
|
||||
nativeSync();
|
||||
}
|
||||
output_file.renameTo(final_file);
|
||||
if (mClose) {
|
||||
mInput.close();
|
||||
}
|
||||
}
|
||||
|
||||
// See jni/android_driver.c:nativeSync()
|
||||
private native void nativeSync();
|
||||
}
|
||||
|
@ -130,9 +130,7 @@ class DiskLoader extends AsyncTask<Void, Void, Boolean> {
|
||||
}
|
||||
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
Boolean result = extractImage();
|
||||
nativeSync(); // Flush new disk images before claiming they are ready.
|
||||
return result;
|
||||
return extractImage();
|
||||
}
|
||||
|
||||
protected void onCancelled(final Boolean result) {
|
||||
@ -142,7 +140,4 @@ class DiskLoader extends AsyncTask<Void, Void, Boolean> {
|
||||
protected void onPostExecute(final Boolean result) {
|
||||
mNotify.onImageReady(result, mImage);
|
||||
}
|
||||
|
||||
// See jni/android_driver.c:nativeSync()
|
||||
private native void nativeSync();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user