Skip to content

Commit

Permalink
Merge pull request #2336 from quran/add_recursive_copy_from_assets
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre authored Aug 4, 2023
2 parents cdfc3c6 + d65c68e commit 22babf2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,30 @@ class QuranFileUtils @Inject constructor(
copyFromAssets(assetsPath, filename, actualDestination)
}

override fun copyFromAssetsRelativeRecursive(
assetsPath: String,
directory: String,
destination: String
) {
val destinationPath = File(getQuranBaseDirectory(appContext) + destination)
val directoryDestinationPath = File(destinationPath, directory)
if (!directoryDestinationPath.exists()) {
directoryDestinationPath.mkdirs()
}

val assets = appContext.assets
val files = assets.list(assetsPath) ?: emptyArray()
val destinationDirectory = "$destination${File.separator}$directory"
files.forEach {
val path = "$assetsPath${File.separator}$it"
if (assets.list(path)?.isNotEmpty() == true) {
copyFromAssetsRelativeRecursive(path, it, destinationDirectory)
} else {
copyFromAssetsRelative(path, it, destinationDirectory)
}
}
}

@WorkerThread
override fun removeOldArabicDatabase(): Boolean {
val databaseQuranArabicDatabase = File(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class ZipUtils {

private static final int BUFFER_SIZE = 512;
private static final int MAX_FILES = 10000; // Max number of files
private static final int MAX_FILES = 12000; // Max number of files

@VisibleForTesting
static int MAX_UNZIPPED_SIZE = 0x1f400000; // Max size of unzipped data, 500MB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ interface QuranFileManager {
@WorkerThread
fun copyFromAssetsRelative(assetsPath: String, filename: String, destination: String)

@WorkerThread
fun copyFromAssetsRelativeRecursive(assetsPath: String, directory: String, destination: String)

@WorkerThread
fun removeOldArabicDatabase(): Boolean

Expand Down

0 comments on commit 22babf2

Please sign in to comment.