weblib: update pg on import
authorNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 12:27:17 +0000 (14:27 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 12:27:17 +0000 (14:27 +0200)
src/be/nikiroo/fanfix/data/MetaData.java
src/be/nikiroo/fanfix/library/WebLibraryServer.java

index 586196a663fea88aa39fe45111445d76df0d5651..bcebf754b7dc2b6ee71204d9aaf8a1efe2c20dbf 100644 (file)
@@ -34,6 +34,12 @@ public class MetaData implements Cloneable, Comparable<MetaData>, Serializable {
        private String creationDate;
        private boolean fakeCover;
 
+       /**
+        * Create an empty {@link MetaData}.
+        */
+       public MetaData() {
+       }
+       
        /**
         * The title of the story.
         * 
@@ -479,8 +485,9 @@ public class MetaData implements Cloneable, Comparable<MetaData>, Serializable {
                }
 
                return String.format(
-                               "Meta %s:\n\tTitle: [%s]\n\tAuthor: [%s]\n\tDate: [%s]\n\tTags: [%s]"
-                                               + "\n\tResume: [%s]\n\tCover: [%s]", luid, title,
-                               getAuthor(), getDate(), tags.toString(), resume, cover);
+                               "Meta %s:\n\tTitle: [%s]\n\tAuthor: [%s]\n\tDate: [%s]\n\tTags: [%s]\n\tWord count: [%s]"
+                                               + "\n\tResume: [%s]\n\tCover: [%s]",
+                               luid, title, getAuthor(), getDate(), tags.toString(),
+                               "" + words, resume, cover);
        }
 }
index 9073b8cad58895f02ccbd88d2a8d2a9deebf6397..b3d897d04bbbb8bf5ecc433cd4dee280e415c7e6 100644 (file)
@@ -28,6 +28,7 @@ import be.nikiroo.utils.NanoHTTPD;
 import be.nikiroo.utils.NanoHTTPD.Response;
 import be.nikiroo.utils.NanoHTTPD.Response.Status;
 import be.nikiroo.utils.Progress;
+import be.nikiroo.utils.Progress.ProgressListener;
 
 public class WebLibraryServer extends WebLibraryServerHtml {
        class WLoginResult extends LoginResult {
@@ -414,6 +415,14 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                final Progress pg = new Progress();
                final String luid = lib.getNextId();
 
+               // Keep the latest name
+               pg.addProgressListener(new ProgressListener() {
+                       @Override
+                       public void progress(Progress progress, String name) {
+                               pg.setName(name);
+                       }
+               });
+
                synchronized (imprts) {
                        imprts.put(luid, pg);
                }