From 086bad30f0007ff7e7c552bc075ff34ee0466087 Mon Sep 17 00:00:00 2001 From: noble Date: Wed, 13 Nov 2019 18:55:29 +1100 Subject: [PATCH] SOLR-13821: Return the size of the file --- .../org/apache/solr/filestore/DistribPackageStore.java | 9 ++++++++- .../src/java/org/apache/solr/filestore/PackageStore.java | 2 ++ .../core/src/java/org/apache/solr/pkg/PackageLoader.java | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java b/solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java index 703102f6262..3e3b5834eaf 100644 --- a/solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java +++ b/solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java @@ -280,6 +280,11 @@ public class DistribPackageStore implements PackageStore { return type == FileType.DIRECTORY; } + @Override + public long size() { + return realPath().toFile().length(); + } + @Override public void writeMap(EntryWriter ew) throws IOException { MetaData metaData = readMetaData(); @@ -288,6 +293,8 @@ public class DistribPackageStore implements PackageStore { ew.put("dir", true); return; } + + ew.put("size", size()); ew.put("timestamp", getTimeStamp()); if (metaData != null) metaData.writeMap(ew); @@ -389,7 +396,7 @@ public class DistribPackageStore implements PackageStore { if (f.fetchFromAnyNode()) { log.info("Successfully downloaded : {}", path); return true; - } else{ + } else { log.info("Unable to download file : {}", path); return false; } diff --git a/solr/core/src/java/org/apache/solr/filestore/PackageStore.java b/solr/core/src/java/org/apache/solr/filestore/PackageStore.java index 8ac23886aba..9a5fbff493e 100644 --- a/solr/core/src/java/org/apache/solr/filestore/PackageStore.java +++ b/solr/core/src/java/org/apache/solr/filestore/PackageStore.java @@ -113,6 +113,8 @@ public interface PackageStore { Date getTimeStamp(); + long size(); + boolean isDir(); diff --git a/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java b/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java index 565ff144d97..8783d9bd827 100644 --- a/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java +++ b/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java @@ -94,7 +94,7 @@ public class PackageLoader implements Closeable { } else { Package p = packageClassLoaders.remove(e.getKey()); if (p != null) { - //other classes are holding to a reference to this objecec + //other classes are holding to a reference to this object // they should know that this is removed p.markDeleted(); closeWhileHandlingException(p);