diff --git a/src/java/org/rapidcontext/app/model/ApiUtil.java b/src/java/org/rapidcontext/app/model/ApiUtil.java index d1016834..4cbe1655 100644 --- a/src/java/org/rapidcontext/app/model/ApiUtil.java +++ b/src/java/org/rapidcontext/app/model/ApiUtil.java @@ -248,7 +248,7 @@ public static Object serialize(Path path, boolean hidden = opts.get("hidden", Boolean.class, false); return new Dict() .set("type", "index") - .set("modified", idx.modified()) + .set("modified", Objects.requireNonNullElse(idx.modified(), new Date())) .set("paths", Array.from(idx.paths(path, hidden))); } else if (obj instanceof Binary) { Binary data = (Binary) obj; diff --git a/src/java/org/rapidcontext/app/plugin/PluginZipStorage.java b/src/java/org/rapidcontext/app/plugin/PluginZipStorage.java index 0fe5961c..52e6a5c3 100644 --- a/src/java/org/rapidcontext/app/plugin/PluginZipStorage.java +++ b/src/java/org/rapidcontext/app/plugin/PluginZipStorage.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.IOException; +import java.util.Date; import org.apache.commons.lang3.StringUtils; import org.rapidcontext.core.storage.Index; @@ -53,7 +54,7 @@ public PluginZipStorage(String pluginId, File zipFile) throws IOException { root.removeObject(legacyPath.name()); paths.remove(legacyPath); entries.remove(legacyPath); - Index idx = new Index(); + Index idx = new Index(new Date()); root.addIndex(Plugin.PATH.name()); paths.put(Plugin.PATH, Plugin.PATH); entries.put(Plugin.PATH, idx); diff --git a/src/java/org/rapidcontext/core/storage/Index.java b/src/java/org/rapidcontext/core/storage/Index.java index 35a611a2..bade4feb 100644 --- a/src/java/org/rapidcontext/core/storage/Index.java +++ b/src/java/org/rapidcontext/core/storage/Index.java @@ -71,17 +71,10 @@ public static Index merge(Index one, Index two) { } } - /** - * Creates a new empty index modified right now. - */ - public Index() { - this(new Date()); - } - /** * Creates a new empty index. * - * @param modified the last modified date + * @param modified the last modified date, or null for unknown */ public Index(Date modified) { this.modified = modified; @@ -121,7 +114,7 @@ public boolean isEmpty() { /** * Returns the last modified date. * - * @return the last modified date + * @return the last modified date, or null if unknown */ public Date modified() { return this.modified; diff --git a/src/java/org/rapidcontext/core/storage/MemoryStorage.java b/src/java/org/rapidcontext/core/storage/MemoryStorage.java index 4f3991f2..759f26f4 100644 --- a/src/java/org/rapidcontext/core/storage/MemoryStorage.java +++ b/src/java/org/rapidcontext/core/storage/MemoryStorage.java @@ -236,13 +236,12 @@ private void remove(Path path, boolean updateParent) { */ private void indexInsert(Path path) { Path parent = path.parent(); - Index idx = Objects.requireNonNullElse((Index) objects.get(parent), new Index()); + Index idx = Objects.requireNonNullElse((Index) objects.get(parent), new Index(null)); if (path.isIndex()) { idx.addIndex(path.name()); } else { idx.addObject(path.name()); } - idx.setModified(null); if (!objects.containsKey(parent)) { objects.put(parent, idx); meta.put(parent, new Metadata(Index.class, parent, Path.ROOT, null)); @@ -267,7 +266,6 @@ private void indexRemove(Path path) { } else { idx.removeObject(path.name()); } - idx.setModified(null); if (idx.isEmpty()) { objects.remove(parent); meta.remove(parent);