diskmanager: clearing disk cache at runtime will correctly signal renderers

Clearing the disk cache in the preferences will correctly communicate to
renderers that those frames are now deleted.
This commit is contained in:
itsmattkc
2020-01-25 12:18:46 +11:00
parent c26070bfb5
commit 3f85ce8a7a
8 changed files with 45 additions and 13 deletions
+13 -1
View File
@@ -64,7 +64,19 @@ endif()
target_compile_definitions(${OLIVE_TARGET} PRIVATE ${OLIVE_DEFINITIONS})
if(MSVC)
target_compile_options(${OLIVE_TARGET} PRIVATE /WX /W4 /wd4127 /wd4456 /wd4706 /experimental:external /external:anglebrackets /external:W0 "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(
${OLIVE_TARGET}
PRIVATE
/WX
/W4
/wd4127
/wd4456
/wd4706
/experimental:external
/external:anglebrackets
/external:W0
"$<$<CONFIG:RELEASE>:/O2>"
)
else()
target_compile_options(${OLIVE_TARGET} PRIVATE -O2 -Werror -Wuninitialized -pedantic-errors -Wall -Wextra -Wconversion -Wsign-conversion)
endif()
@@ -112,7 +112,7 @@ void PreferencesDiskTab::ClearDiskCache()
tr("Clear Disk Cache"),
tr("Are you sure you want to clear the disk cache in '%1'?").arg(Config::Current()["DiskCachePath"].toString()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
if (DiskManager::instance()->ClearDiskCache()) {
if (DiskManager::instance()->ClearDiskCache(false)) {
QMessageBox::information(this,
tr("Clear Disk Cache"),
tr("Disk cache cleared successfully"),
+2 -2
View File
@@ -303,14 +303,14 @@ void VideoRenderBackend::ThreadCompletedFrame(NodeDependency path, qint64 job_ti
}
}
void VideoRenderBackend::ThreadCompletedDownload(NodeDependency dep, qint64 job_time, QByteArray hash)
void VideoRenderBackend::ThreadCompletedDownload(NodeDependency dep, qint64 job_time, QByteArray hash, bool texture_existed)
{
SetWorkerBusyState(static_cast<RenderWorker*>(sender()), false);
SetFrameHash(dep, hash, job_time);
// Register frame with the disk manager
if (operating_mode_ & VideoRenderWorker::kDownloadOnly) {
if (texture_existed && operating_mode_ & VideoRenderWorker::kDownloadOnly) {
DiskManager::instance()->CreatedFile(frame_cache()->CachePathName(hash, params_.format()), hash);
}
+1 -1
View File
@@ -140,7 +140,7 @@ private:
private slots:
void ThreadCompletedFrame(NodeDependency path, qint64 job_time, QByteArray hash, QVariant value);
void ThreadCompletedDownload(NodeDependency dep, qint64 job_time, QByteArray hash);
void ThreadCompletedDownload(NodeDependency dep, qint64 job_time, QByteArray hash, bool texture_existed);
void ThreadSkippedFrame(NodeDependency dep, qint64 job_time, QByteArray hash);
void ThreadHashAlreadyExists(NodeDependency dep, qint64 job_time, QByteArray hash);
+2 -2
View File
@@ -47,7 +47,7 @@ NodeValueTable VideoRenderWorker::RenderInternal(const NodeDependency& path, con
if (!(operating_mode_ & kRenderOnly)) {
// Emit only the hash
emit CompletedDownload(path, job_time, hash);
emit CompletedDownload(path, job_time, hash, false);
} else if ((operating_mode_ & kHashOnly) && frame_cache_->HasHash(hash, video_params_.format())) {
@@ -74,7 +74,7 @@ NodeValueTable VideoRenderWorker::RenderInternal(const NodeDependency& path, con
if (operating_mode_ & kDownloadOnly) {
// Signal that this job is complete
emit CompletedDownload(path, job_time, hash);
emit CompletedDownload(path, job_time, hash, !texture.isNull());
}
} else {
+1 -1
View File
@@ -50,7 +50,7 @@ public:
signals:
void CompletedFrame(NodeDependency path, qint64 job_time, QByteArray hash, QVariant value);
void CompletedDownload(NodeDependency path, qint64 job_time, QByteArray hash);
void CompletedDownload(NodeDependency path, qint64 job_time, QByteArray hash, bool texture_existed);
void HashAlreadyBeingCached(NodeDependency path, qint64 job_time, QByteArray hash);
+24 -4
View File
@@ -41,7 +41,7 @@ DiskManager::~DiskManager()
{
if (Config::Current()["ClearDiskCacheOnClose"].toBool()) {
// Clear all cache data
ClearDiskCache();
ClearDiskCache(true);
} else {
// Save current cache index
QFile cache_index_file(GetCacheIndexFilename());
@@ -142,13 +142,33 @@ void DiskManager::CreatedFile(const QString &file_name, const QByteArray &hash)
}
}
bool DiskManager::ClearDiskCache()
bool DiskManager::ClearDiskCache(bool quick_delete)
{
bool deleted_files;
lock_.lock();
bool deleted_files = QDir(GetMediaCacheLocation()).removeRecursively();
if (quick_delete) {
deleted_files = QDir(GetMediaCacheLocation()).removeRecursively();
disk_data_.clear();
disk_data_.clear();
} else {
deleted_files = true;
for (int i=0;i<disk_data_.size();i++) {
const HashTime& ht = disk_data_.at(i);
// We return a false result if any of the files fail to delete, but still try to delete as many as we can
if (QFile::remove(ht.file_name)) {
emit DeletedFrame(ht.hash);
disk_data_.removeAt(i);
i--;
} else {
qWarning() << "Failed to delete" << ht.file_name;
deleted_files = false;
}
}
}
lock_.unlock();
+1 -1
View File
@@ -20,7 +20,7 @@ public:
void CreatedFile(const QString& file_name, const QByteArray& hash);
bool ClearDiskCache();
bool ClearDiskCache(bool quick_delete);
signals:
void DeletedFrame(const QByteArray& hash);