Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for 3.2.55 (tier 3) #279

Merged
merged 6 commits into from
Apr 19, 2021
Prev Previous commit
Next Next commit
Synchronizer related: fixed scanning of just downloaded books in zip …
…archive.
  • Loading branch information
virxkane committed Apr 19, 2021
commit 31333936a34f56eed605da1c539263a8c21e71d6
24 changes: 16 additions & 8 deletions android/src/org/coolreader/crengine/Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,26 @@ public boolean listDirectory(FileInfo baseDir) {
return listDirectory(baseDir, true, true);
}

public boolean listDirectory(FileInfo baseDir, boolean onlySupportedFormats, boolean scanzip) {
return listDirectory(baseDir, onlySupportedFormats, scanzip, false);
}

/**
* Adds dir and file children to directory FileInfo item.
* @param baseDir is directory to list files and dirs for
* @param onlySupportedFormats list only supported files
* @param scanzip scan zip-files
* @param rescan full directory rescan
* @return true if successful.
*/
public boolean listDirectory(FileInfo baseDir, boolean onlySupportedFormats, boolean scanzip)
public boolean listDirectory(FileInfo baseDir, boolean onlySupportedFormats, boolean scanzip, boolean rescan)
{
Set<String> knownItems = null;
if ( baseDir.isListed ) {
knownItems = new HashSet<String>();
for ( int i=baseDir.itemCount()-1; i>=0; i-- ) {
FileInfo item = baseDir.getItem(i);
if ( !item.exists() ) {
if ( !item.exists() || rescan ) {
// remove item from list
baseDir.removeChild(item);
} else {
Expand Down Expand Up @@ -152,7 +159,7 @@ public boolean listDirectory(FileInfo baseDir, boolean onlySupportedFormats, boo
continue;
}
boolean isZip = pathName.toLowerCase().endsWith(".zip");
FileInfo item = mFileList.get(pathName);
FileInfo item = !rescan ? mFileList.get(pathName) : null;
boolean isNew = false;
if ( item==null ) {
item = new FileInfo( f );
Expand Down Expand Up @@ -322,16 +329,16 @@ private void scanDirectoryFiles(final CRDBService.LocalBinder db, final FileInfo
break;
progress.setProgress((i + count) * 10000 / (2*count));
FileInfo item = filesForParsing.get(i);
engine.scanBookProperties(item);
filesForSave1.add(item);
if (engine.scanBookProperties(item))
filesForSave1.add(item);
}
for ( int i=0; i<count2; i++ ) {
if (control.isStopped())
break;
progress.setProgress((i + count) * 10000 / (2*count));
FileInfo item = filesForCRC32Update.get(i);
Engine.updateFileCRC32(item);
filesForSave1.add(item);
if (Engine.updateFileCRC32(item))
filesForSave1.add(item);
}
} catch (Exception e) {
L.e("Exception while scanning", e);
Expand Down Expand Up @@ -755,7 +762,8 @@ private boolean listSubtreeBg_impl(FileInfo dir, int maxDepth, ScanControl scanC
boolean fullDepthScan = true;
if (maxDepth <= 0 || scanControl.isStopped())
return false;
boolean res = listDirectory(dir, true, true);
// full rescan to scan zip-files
boolean res = listDirectory(dir, true, true, !dir.isSpecialDir());
if (res) {
for (int i = dir.dirCount() - 1; i >= -0; i--) {
res = listSubtreeBg_impl(dir.getDir(i), maxDepth - 1, scanControl);
Expand Down