+ List<File> files = getFiles(luid);
+ if (!files.isEmpty()) {
+ for (File file : files) {
+ IOUtils.deltree(file);
+ }
+
+ ok = true;
+
+ // clear cache
+ stories.clear();
+ }
+
+ return ok;
+ }
+
+ /**
+ * Change the type (source) of the given {@link Story}.
+ *
+ * @param luid
+ * the {@link Story} LUID
+ * @param newSourcethe
+ * new source
+ *
+ * @return TRUE if the {@link Story} was found
+ */
+ public synchronized boolean changeType(String luid, String newType) {
+ MetaData meta = getInfo(luid);
+ if (meta != null) {
+ meta.setSource(newType);
+ File newDir = getDir(meta.getSource());
+ if (!newDir.exists()) {
+ newDir.mkdir();
+ }
+
+ List<File> files = getFiles(luid);
+ for (File file : files) {
+ if (file.getName().endsWith(".info")) {
+ try {
+ String name = file.getName().replaceFirst("\\.info$",
+ "");
+ InfoCover.writeInfo(newDir, name, meta);
+ file.delete();
+ } catch (IOException e) {
+ Instance.syserr(e);
+ }
+ } else {
+ file.renameTo(new File(newDir, file.getName()));
+ }
+ }
+
+ // clear cache
+ stories.clear();
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return the list of files/dirs on disk for this {@link Story}.
+ * <p>
+ * If the {@link Story} is not found, and empty list is returned.
+ *
+ * @param luid
+ * the {@link Story} LUID
+ *
+ * @return the list of {@link File}s
+ */
+ private List<File> getFiles(String luid) {
+ List<File> files = new ArrayList<File>();
+