[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [onionoo/master] Add warnings for oversize documents.
commit 5abb70205061049f7a7c681f618f55d0f421f7bf
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Mon Dec 8 08:58:41 2014 +0100
Add warnings for oversize documents.
---
.../java/org/torproject/onionoo/docs/DocumentStore.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
index 5137fb4..4b7bca5 100644
--- a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
+++ b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
@@ -278,6 +278,10 @@ public class DocumentStore {
return true;
}
+ private static final long ONE_BYTE = 1L,
+ ONE_KIBIBYTE = 1024L * ONE_BYTE,
+ ONE_MIBIBYTE = 1024L * ONE_KIBIBYTE;
+
private <T extends Document> boolean storeDocumentFile(T document,
String fingerprint) {
File documentFile = this.getDocumentFile(document.getClass(),
@@ -328,6 +332,11 @@ public class DocumentStore {
return false;
}
try {
+ if (documentString.length() > ONE_MIBIBYTE) {
+ log.warn("Attempting to store very large document file: path='"
+ + documentFile.getAbsolutePath() + "', bytes="
+ + documentString.length());
+ }
documentFile.getParentFile().mkdirs();
File documentTempFile = new File(
documentFile.getAbsolutePath() + ".tmp");
@@ -452,6 +461,11 @@ public class DocumentStore {
+ documentFile.getAbsolutePath() + "'.", e);
return null;
}
+ if (documentString.length() > ONE_MIBIBYTE) {
+ log.warn("Retrieved very large document file: path='"
+ + documentFile.getAbsolutePath() + "', bytes="
+ + documentString.length());
+ }
T result = null;
if (!parse) {
return this.retrieveUnparsedDocumentFile(documentType,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits