Fix --export
authorNiki Roo <niki@nikiroo.be>
Mon, 13 Feb 2017 06:31:57 +0000 (07:31 +0100)
committerNiki Roo <niki@nikiroo.be>
Mon, 13 Feb 2017 06:31:57 +0000 (07:31 +0100)
--export did not correctly pass the LUID to the library

src/be/nikiroo/fanfix/Library.java
src/be/nikiroo/fanfix/Main.java

index 68f93c5385c66ea52c7f4bd2fd6d43eb8ed8bb3b..15b81e44db7aca3caf8869f8f0b53539e1ddb8aa 100644 (file)
@@ -194,6 +194,11 @@ public class Library {
                        throw new IOException("Output type not supported: " + type);
                }
 
+               Story story = getStory(luid);
+               if (story == null) {
+                       throw new IOException("Cannot find story to export: " + luid);
+               }
+
                return out.process(getStory(luid), target);
        }
 
index 0938fea9b2ca9fd2e87f96a5a7307cab3060e876..d5669d56622750e754ae9a8288221a0f2c531872 100644 (file)
@@ -64,7 +64,7 @@ public class Main {
                String target = null;
                MainAction action = MainAction.HELP;
                Boolean plusInfo = null;
-               
+
                boolean noMoreActions = false;
 
                int exitCode = 0;
@@ -163,7 +163,7 @@ public class Main {
                                exitCode = imprt(urlString);
                                break;
                        case EXPORT:
-                               exitCode = export(urlString, typeString, target);
+                               exitCode = export(luid, typeString, target);
                                break;
                        case CONVERT:
                                exitCode = convert(urlString, typeString, target,
@@ -248,7 +248,7 @@ public class Main {
        /**
         * Export the {@link Story} from the {@link Library} to the given target.
         * 
-        * @param urlString
+        * @param luid
         *            the story LUID
         * @param typeString
         *            the {@link OutputType} to use
@@ -257,7 +257,7 @@ public class Main {
         * 
         * @return the exit return code (0 = success)
         */
-       private static int export(String urlString, String typeString, String target) {
+       private static int export(String luid, String typeString, String target) {
                OutputType type = OutputType.valueOfNullOkUC(typeString);
                if (type == null) {
                        Instance.syserr(new Exception(trans(StringId.OUTPUT_DESC,
@@ -266,9 +266,7 @@ public class Main {
                }
 
                try {
-                       Story story = Instance.getLibrary().imprt(new URL(urlString));
-                       Instance.getLibrary().export(story.getMeta().getLuid(), type,
-                                       target);
+                       Instance.getLibrary().export(luid, type, target);
                } catch (IOException e) {
                        Instance.syserr(e);
                        return 4;