mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-21 19:41:38 -04:00
Better log for FileUtils::doesFileExist() #6
This commit is contained in:
parent
1e280d99ca
commit
372b725749
@ -460,11 +460,10 @@ def step_embed_zimfile(jsdata, **options):
|
|||||||
os.symlink('../{}/{}'.format(archs[0], jsdata.get('zim_name')),
|
os.symlink('../{}/{}'.format(archs[0], jsdata.get('zim_name')),
|
||||||
jsdata.get('zim_name'))
|
jsdata.get('zim_name'))
|
||||||
os.chdir(tmpd)
|
os.chdir(tmpd)
|
||||||
syscall('zip -r -0 {} lib'
|
syscall('zip -r -0 -y {} lib'
|
||||||
.format(os.path.join(ANDROID_PATH, 'content-libs.jar')))
|
.format(os.path.join(ANDROID_PATH, 'content-libs.jar')))
|
||||||
shutil.rmtree(tmpd)
|
shutil.rmtree(tmpd)
|
||||||
|
|
||||||
|
|
||||||
def step_build_apk(jsdata, **options):
|
def step_build_apk(jsdata, **options):
|
||||||
''' build the actual APK '''
|
''' build the actual APK '''
|
||||||
|
|
||||||
|
@ -1123,11 +1123,8 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
filePath = FileUtils.generateSaveFileName(fileName);
|
filePath = FileUtils.generateSaveFileName(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG_KIWIX, "Looking for: " + filePath + " -- filesize: "
|
|
||||||
+ Constants.CUSTOM_APP_ZIM_FILE_SIZE);
|
|
||||||
if (!FileUtils
|
if (!FileUtils
|
||||||
.doesFileExist(filePath, Constants.CUSTOM_APP_ZIM_FILE_SIZE, false)) {
|
.doesFileExist(filePath, Constants.CUSTOM_APP_ZIM_FILE_SIZE, false)) {
|
||||||
Log.d(TAG_KIWIX, "... doesn't exist.");
|
|
||||||
|
|
||||||
AlertDialog.Builder zimFileMissingBuilder = new AlertDialog.Builder(
|
AlertDialog.Builder zimFileMissingBuilder = new AlertDialog.Builder(
|
||||||
this);
|
this);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.kiwix.kiwixmobile.utils.files;
|
package org.kiwix.kiwixmobile.utils.files;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -7,6 +8,8 @@ import org.kiwix.kiwixmobile.settings.Constants;
|
|||||||
|
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
|
|
||||||
|
public static final String TAG_KIWIX = "kiwix";
|
||||||
|
|
||||||
public static File getFileCacheDir(Context context) {
|
public static File getFileCacheDir(Context context) {
|
||||||
boolean external = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
|
boolean external = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
|
||||||
|
|
||||||
@ -61,18 +64,27 @@ public class FileUtils {
|
|||||||
*/
|
*/
|
||||||
static public boolean doesFileExist(String fileName, long fileSize,
|
static public boolean doesFileExist(String fileName, long fileSize,
|
||||||
boolean deleteFileOnMismatch) {
|
boolean deleteFileOnMismatch) {
|
||||||
|
|
||||||
|
Log.d(TAG_KIWIX, "Looking for '" + fileName + "' with size=" + fileSize);
|
||||||
|
|
||||||
// the file may have been delivered by Market --- let's make sure
|
// the file may have been delivered by Market --- let's make sure
|
||||||
// it's the size we expect
|
// it's the size we expect
|
||||||
File fileForNewFile = new File(fileName);
|
File fileForNewFile = new File(fileName);
|
||||||
if (fileForNewFile.exists()) {
|
if (fileForNewFile.exists()) {
|
||||||
if (fileForNewFile.length() == fileSize) {
|
if (fileForNewFile.length() == fileSize) {
|
||||||
|
Log.d(TAG_KIWIX, "Correct file '" + fileName + "' found.");
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
Log.d(TAG_KIWIX, "File '" + fileName + "' found but with wrong size=" + fileForNewFile.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleteFileOnMismatch) {
|
if (deleteFileOnMismatch) {
|
||||||
// delete the file --- we won't be able to resume
|
// delete the file --- we won't be able to resume
|
||||||
// because we cannot confirm the integrity of the file
|
// because we cannot confirm the integrity of the file
|
||||||
fileForNewFile.delete();
|
fileForNewFile.delete();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(TAG_KIWIX, "No file '" + fileName + "' found.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user