mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 19:34:39 +01:00
Merge pull request #8556 from unknownbrackets/diskcache
Correct recovery of locked disk cache files
This commit is contained in:
commit
6accac3b33
1 file changed
+9
@@ -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());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user