diff --git a/gen-custom-android-build.py b/gen-custom-android-build.py index 87e868c43..68ed447b9 100755 --- a/gen-custom-android-build.py +++ b/gen-custom-android-build.py @@ -460,11 +460,10 @@ def step_embed_zimfile(jsdata, **options): os.symlink('../{}/{}'.format(archs[0], jsdata.get('zim_name')), jsdata.get('zim_name')) os.chdir(tmpd) - syscall('zip -r -0 {} lib' + syscall('zip -r -0 -y {} lib' .format(os.path.join(ANDROID_PATH, 'content-libs.jar'))) shutil.rmtree(tmpd) - def step_build_apk(jsdata, **options): ''' build the actual APK ''' diff --git a/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java index 46b0f97fb..58999abc8 100644 --- a/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -1123,11 +1123,8 @@ public class KiwixMobileActivity extends AppCompatActivity filePath = FileUtils.generateSaveFileName(fileName); } - Log.d(TAG_KIWIX, "Looking for: " + filePath + " -- filesize: " - + Constants.CUSTOM_APP_ZIM_FILE_SIZE); if (!FileUtils .doesFileExist(filePath, Constants.CUSTOM_APP_ZIM_FILE_SIZE, false)) { - Log.d(TAG_KIWIX, "... doesn't exist."); AlertDialog.Builder zimFileMissingBuilder = new AlertDialog.Builder( this); diff --git a/src/org/kiwix/kiwixmobile/utils/files/FileUtils.java b/src/org/kiwix/kiwixmobile/utils/files/FileUtils.java index bb891c24a..ee45e2cbe 100644 --- a/src/org/kiwix/kiwixmobile/utils/files/FileUtils.java +++ b/src/org/kiwix/kiwixmobile/utils/files/FileUtils.java @@ -1,5 +1,6 @@ package org.kiwix.kiwixmobile.utils.files; +import android.util.Log; import android.content.Context; import android.os.Environment; import java.io.File; @@ -7,6 +8,8 @@ import org.kiwix.kiwixmobile.settings.Constants; public class FileUtils { + public static final String TAG_KIWIX = "kiwix"; + public static File getFileCacheDir(Context context) { boolean external = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); @@ -61,18 +64,27 @@ public class FileUtils { */ static public boolean doesFileExist(String fileName, long fileSize, boolean deleteFileOnMismatch) { + + Log.d(TAG_KIWIX, "Looking for '" + fileName + "' with size=" + fileSize); + // the file may have been delivered by Market --- let's make sure // it's the size we expect File fileForNewFile = new File(fileName); if (fileForNewFile.exists()) { if (fileForNewFile.length() == fileSize) { + Log.d(TAG_KIWIX, "Correct file '" + fileName + "' found."); return true; + } else { + Log.d(TAG_KIWIX, "File '" + fileName + "' found but with wrong size=" + fileForNewFile.length()); } + if (deleteFileOnMismatch) { // delete the file --- we won't be able to resume // because we cannot confirm the integrity of the file fileForNewFile.delete(); } + } else { + Log.d(TAG_KIWIX, "No file '" + fileName + "' found."); } return false; }