mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Correct recovery of locked disk cache files.
We were keeping the index when creating a new file, rather than clearing it. Additionally, flush before all reads - in case of overlap.
This commit is contained in:
parent
609c8eb29f
commit
0517d3721c
1 changed files with 9 additions and 0 deletions
|
@ -422,6 +422,10 @@ bool DiskCachingFileLoaderCache::ReadBlockData(u8 *dest, BlockInfo &info, size_t
|
|||
}
|
||||
s64 blockOffset = GetBlockOffset(info.block);
|
||||
|
||||
// Before we read, make sure the buffers are flushed.
|
||||
// We might be trying to read an area we've recently written.
|
||||
fflush(f_);
|
||||
|
||||
bool failed = false;
|
||||
#ifdef ANDROID
|
||||
if (lseek64(fd_, blockOffset, SEEK_SET) != blockOffset) {
|
||||
|
@ -615,6 +619,7 @@ void DiskCachingFileLoaderCache::CreateCacheFile(const std::string &path) {
|
|||
}
|
||||
|
||||
indexCount_ = (filesize_ + blockSize_ - 1) / blockSize_;
|
||||
index_.clear();
|
||||
index_.resize(indexCount_);
|
||||
blockIndexLookup_.resize(maxBlocks_);
|
||||
memset(&blockIndexLookup_[0], INVALID_INDEX, maxBlocks_ * sizeof(blockIndexLookup_[0]));
|
||||
|
@ -623,6 +628,10 @@ void DiskCachingFileLoaderCache::CreateCacheFile(const std::string &path) {
|
|||
CloseFileHandle();
|
||||
return;
|
||||
}
|
||||
if (fflush(f_) != 0) {
|
||||
CloseFileHandle();
|
||||
return;
|
||||
}
|
||||
|
||||
INFO_LOG(LOADER, "Created new disk cache file for %s", origPath_.c_str());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue