Commit a3a8c976 authored by Ivanq's avatar Ivanq

Remove peekFile cache because of ZeroNet issue #1232

parent 20813fd6
......@@ -200,32 +200,7 @@ class Hg {
return this.zeroFS.readFile(this.root + "/" + path, "arraybuffer");
}
peekFile(path, offset, length) {
// Split file by 1 KB
let chunkSize = 1024; // 1 KB
let newOffset = offset - offset % chunkSize;
let newLength = Math.ceil((offset + length) / chunkSize) * chunkSize - newOffset;
if(!this.peekFile.cache) {
this.peekFile.cache = {};
}
if(!this.peekFile.cache[path]) {
this.peekFile.cache[path] = {};
}
let promise = Promise.resolve();
if(!this.peekFile.cache[path][newOffset + "|" + newLength]) {
promise = this.zeroFS.peekFile(this.root + "/" + path, newOffset, newLength, "arraybuffer")
.then(res => {
this.peekFile.cache[path][newOffset + "|" + newLength] = res;
});
}
return promise
.then(() => {
let cache = this.peekFile.cache[path][newOffset + "|" + newLength];
return this.subArray(cache, offset - newOffset, length);
});
return this.zeroFS.peekFile(this.root + "/" + path, offset, length, "arraybuffer");
}
readDirectory(path, recursive) {
return this.zeroFS.readDirectory(this.root + "/" + path, recursive);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment