SOLR-13821: Return the size of the file

This commit is contained in:
noble 2019-11-13 18:55:29 +11:00
parent 550c7296b6
commit 59cc299c7e
3 changed files with 11 additions and 2 deletions

View File

@ -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;
}

View File

@ -113,6 +113,8 @@ public interface PackageStore {
Date getTimeStamp();
long size();
boolean isDir();

View File

@ -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);