use of org.ebookdroid.droids.mupdf.codec.exceptions.MuPdfPasswordRequiredException in project LibreraReader by foobnix.
the class AbstractCodecContext method openDocument.
@Override
public CodecDocument openDocument(String fileNameOriginal, String password) {
LOG.d("Open-Document", fileNameOriginal);
// TempHolder.get().loadingCancelled = false;
if (ExtUtils.isZip(fileNameOriginal)) {
LOG.d("Open-Document ZIP", fileNameOriginal);
return openDocumentInnerCanceled(fileNameOriginal, password);
}
LOG.d("Open-Document 2 LANG:", BookCSS.get().hypenLang, fileNameOriginal);
File cacheFileName = getCacheFileName(fileNameOriginal);
CacheZipUtils.removeFiles(CacheZipUtils.CACHE_BOOK_DIR.listFiles(), cacheFileName);
if (cacheFileName != null && cacheFileName.isFile()) {
LOG.d("Open-Document from cache", fileNameOriginal);
return openDocumentInnerCanceled(fileNameOriginal, password);
}
CacheZipUtils.cacheLock.lock();
CacheZipUtils.createAllCacheDirs();
try {
String fileName = CacheZipUtils.extracIfNeed(fileNameOriginal, CacheDir.ZipApp).unZipPath;
LOG.d("Open-Document extract", fileName);
if (!ExtUtils.isValidFile(fileName)) {
return null;
}
try {
return openDocumentInnerCanceled(fileName, password);
} catch (MuPdfPasswordException e) {
throw new MuPdfPasswordRequiredException();
} catch (Throwable e) {
LOG.e(e);
return null;
}
} finally {
CacheZipUtils.cacheLock.unlock();
}
}
Aggregations