- public Story process(URL url) throws IOException {
- Story story = processMeta(url, false, true);
- story.setChapters(new ArrayList<Chapter>());
- Chapter chap = new Chapter(1, null);
- story.getChapters().add(chap);
-
- ZipInputStream zipIn = new ZipInputStream(getInput());
-
- for (ZipEntry entry = zipIn.getNextEntry(); entry != null; entry = zipIn
- .getNextEntry()) {
- if (!entry.isDirectory()
- && entry.getName().startsWith(getDataPrefix())) {
- String entryLName = entry.getName().toLowerCase();
- boolean imageEntry = false;
- for (String ext : getImageExt(false)) {
- if (entryLName.endsWith(ext)) {
- imageEntry = true;
+ public Story doProcess(Progress pg) throws IOException {
+ if (pg == null) {
+ pg = new Progress();
+ } else {
+ pg.setMinMax(0, 100);
+ }
+
+ pg.setName("Initialising");
+
+ Progress pgMeta = new Progress();
+ pg.addProgress(pgMeta, 10);
+ Story story = processMeta(true, pgMeta);
+ MetaData meta = story.getMeta();
+
+ pgMeta.done(); // 10%
+
+ File tmpDir = Instance.getInstance().getTempFiles().createTempDir("info-text");
+ String basename = null;
+
+ Map<String, Image> images = new HashMap<String, Image>();
+ InputStream cbzIn = null;
+ ZipInputStream zipIn = null;
+ try {
+ cbzIn = new MarkableFileInputStream(getSourceFileOriginal());
+ zipIn = new ZipInputStream(cbzIn);
+ for (ZipEntry entry = zipIn.getNextEntry(); entry != null; entry = zipIn
+ .getNextEntry()) {
+ if (!entry.isDirectory()
+ && entry.getName().startsWith(getDataPrefix())) {
+ String entryLName = entry.getName().toLowerCase();
+ boolean imageEntry = false;
+ for (String ext : bsImages.getImageExt(false)) {
+ if (entryLName.endsWith(ext)) {
+ imageEntry = true;
+ }
+ }
+
+ if (imageEntry) {
+ String uuid = meta.getUuid() + "_" + entry.getName();
+ try {
+ Image img = new Image(zipIn);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ images.put(uuid, img);
+ } catch (Exception e) {
+ Instance.getInstance().getTraceHandler().error(e);
+ }
+
+ if (pg.getProgress() < 85) {
+ pg.add(1);
+ }
+ } else if (entryLName.endsWith(".info")) {
+ basename = entryLName.substring(0, entryLName.length()
+ - ".info".length());
+ IOUtils.write(zipIn, new File(tmpDir, entryLName));
+ } else if (entryLName.endsWith(".txt")) {
+ IOUtils.write(zipIn, new File(tmpDir, entryLName));