From 360d6a22e04e4ec6221dc8a959d2873a90d060d2 Mon Sep 17 00:00:00 2001 From: casey langen Date: Mon, 12 Oct 2020 00:51:06 -0700 Subject: [PATCH] HttpDataStream/LruDiskCache fixes. --- src/plugins/httpdatastream/HttpDataStream.cpp | 11 ++++++++--- src/plugins/httpdatastream/LruDiskCache.cpp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/httpdatastream/HttpDataStream.cpp b/src/plugins/httpdatastream/HttpDataStream.cpp index b658ec6a0..6c5099a6e 100755 --- a/src/plugins/httpdatastream/HttpDataStream.cpp +++ b/src/plugins/httpdatastream/HttpDataStream.cpp @@ -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"); diff --git a/src/plugins/httpdatastream/LruDiskCache.cpp b/src/plugins/httpdatastream/LruDiskCache.cpp index 2bf144e45..e1682b7c1 100644 --- a/src/plugins/httpdatastream/LruDiskCache.cpp +++ b/src/plugins/httpdatastream/LruDiskCache.cpp @@ -152,7 +152,7 @@ LruDiskCache::EntryPtr LruDiskCache::Parse(const fs::path& path) { try { auto entry = std::shared_ptr(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, "-", "/");