cache InfoHash instnance in SharedFile

pull/53/head
Zlatin Balevsky 2020-12-08 07:44:00 +00:00
parent 26561a1b5b
commit 759136cff3
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 5 additions and 1 deletions

View File

@ -20,6 +20,7 @@ public class SharedFile {
private final File file;
private final byte[] root;
private final InfoHash rootInfoHash;
private final int pieceSize;
private final String cachedPath;
@ -37,6 +38,7 @@ public class SharedFile {
public SharedFile(File file, byte[] root, int pieceSize) throws IOException {
this.file = file;
this.root = root;
this.rootInfoHash = new InfoHash(root);
this.pieceSize = pieceSize;
this.cachedPath = file.getAbsolutePath();
this.cachedLength = file.length();
@ -64,6 +66,8 @@ public class SharedFile {
return root;
}
public InfoHash getRootInfoHash() {return rootInfoHash;}
public int getPieceSize() {
return pieceSize;
}

View File

@ -361,7 +361,7 @@ class MainFrameView {
closureColumn(header : trans("COMMENTS"), preferredWidth : 50, type : Boolean, read : {it.getComment() != null})
closureColumn(header : trans("CERTIFIED"), preferredWidth : 50, type : Boolean, read : {
Core core = application.context.get("core")
core.certificateManager.hasLocalCertificate(new InfoHash(it.getRoot()))
core.certificateManager.hasLocalCertificate(it.getRootInfoHash())
})
closureColumn(header : trans("PUBLISHED"), preferredWidth : 50, type : Boolean, read : {row -> row.isPublished()})
closureColumn(header : trans("SEARCH_HITS"), preferredWidth: 50, type : Integer, read : {it.getHits()})