HttpDataStream/LruDiskCache fixes.

This commit is contained in:
casey langen 2020-10-12 00:51:06 -07:00
parent 1b8cd6bb7f
commit 360d6a22e0
2 changed files with 9 additions and 4 deletions

View File

@ -271,9 +271,14 @@ bool HttpDataStream::Open(const char *rawUri, OpenFlags flags) {
if (diskCache.Cached(id)) {
FILE* file = diskCache.Open(id, "rb", this->type, this->length);
this->reader.reset(new FileReadStream(file, this->length));
this->state = Cached;
return true;
if (file) {
this->reader.reset(new FileReadStream(file, this->length));
this->state = Cached;
return true;
}
else {
diskCache.Delete(id);
}
}
this->writeFile = diskCache.Open(id, "wb");

View File

@ -152,7 +152,7 @@ LruDiskCache::EntryPtr LruDiskCache::Parse(const fs::path& path) {
try {
auto entry = std::shared_ptr<Entry>(new Entry());
entry->id = std::stoull(parts[1].c_str());
entry->path = fn;
entry->path = path.string();
entry->type = parts[2];
entry->time = fs::last_write_time(path);
al::replace_all(entry->type, "-", "/");