+ /**
+ * Set the author cover to the given story cover.
+ *
+ * @param author
+ * the author to change
+ * @param coverImage
+ * the cover image
+ */
+ void setAuthorCover(String author, Image coverImage) {
+ File cover = getAuthorCoverFile(author);
+ cover.getParentFile().mkdirs();
+ try {
+ Instance.getInstance().getCache().saveAsImage(coverImage, cover,
+ true);
+ synchronized (lock) {
+ if (authorCovers != null) {
+ authorCovers.put(author, coverImage);
+ }
+ }
+ } catch (IOException e) {
+ Instance.getInstance().getTraceHandler().error(e);
+ }
+ }
+
+ @Override
+ public void imprt(BasicLibrary other, String luid, Progress pg)
+ throws IOException {
+ if (pg == null) {
+ pg = new Progress();
+ }
+
+ // Check if we can simply copy the files instead of the whole process
+ if (other instanceof LocalLibrary) {
+ LocalLibrary otherLocalLibrary = (LocalLibrary) other;
+
+ MetaData meta = otherLocalLibrary.getInfo(luid);
+ String expectedType = ""
+ + (meta != null && meta.isImageDocument() ? image : text);
+ if (meta != null && meta.getType().equals(expectedType)) {
+ File from = otherLocalLibrary.getExpectedDir(meta.getSource());
+ File to = this.getExpectedDir(meta.getSource());
+ List<File> relatedFiles = otherLocalLibrary
+ .getRelatedFiles(luid);
+ if (!relatedFiles.isEmpty()) {
+ pg.setMinMax(0, relatedFiles.size());
+ }
+
+ for (File relatedFile : relatedFiles) {
+ File target = new File(relatedFile.getAbsolutePath()
+ .replace(from.getAbsolutePath(),
+ to.getAbsolutePath()));
+ if (!relatedFile.equals(target)) {
+ target.getParentFile().mkdirs();
+ InputStream in = null;
+ try {
+ in = new FileInputStream(relatedFile);
+ IOUtils.write(in, target);
+ } catch (IOException e) {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (Exception ee) {
+ }
+ }
+
+ pg.done();
+ throw e;
+ }
+ }
+
+ pg.add(1);
+ }
+
+ invalidateInfo();
+ pg.done();
+ return;
+ }
+ }
+
+ super.imprt(other, luid, pg);
+ }
+