diff --git a/app/node/project/footage/footage.cpp b/app/node/project/footage/footage.cpp index 1bf2dc05a..55f4043e4 100644 --- a/app/node/project/footage/footage.cpp +++ b/app/node/project/footage/footage.cpp @@ -90,12 +90,8 @@ void Footage::InputValueChangedEvent(const QString &input, int element) FootageDescription footage_info; - if (QFileInfo::exists(meta_cache_file)) { - - // Load meta cache file - footage_info.Load(meta_cache_file); - - } else { + // Try to load footage info from cache + if (!QFileInfo::exists(meta_cache_file) || !footage_info.Load(meta_cache_file)) { // Probe and create cache QVector decoder_list = Decoder::ReceiveListOfAllDecoders(); diff --git a/app/node/project/footage/footagedescription.cpp b/app/node/project/footage/footagedescription.cpp index 790f264ae..794919496 100644 --- a/app/node/project/footage/footagedescription.cpp +++ b/app/node/project/footage/footagedescription.cpp @@ -40,6 +40,20 @@ bool FootageDescription::Load(const QString &filename) while (XMLReadNextStartElement(&reader)) { if (reader.name() == QStringLiteral("streamcache")) { + // Default to first version of metadata (which wasn't versioned at all) + unsigned version = 1; + + XMLAttributeLoop((&reader), attr) { + if (attr.name() == QStringLiteral("version")) { + version = attr.value().toUInt(); + } + } + + if (version != kFootageMetaVersion) { + // If this is a different version, discard so we can probe new data + return false; + } + while (XMLReadNextStartElement(&reader)) { if (reader.name() == QStringLiteral("decoder")) { decoder_ = reader.readElementText(); @@ -68,7 +82,11 @@ bool FootageDescription::Load(const QString &filename) file.close(); - return true; + if (reader.hasError()) { + qWarning() << "Failed to load footage description for" << filename << reader.errorString(); + } else { + return true; + } } return false; @@ -88,6 +106,8 @@ bool FootageDescription::Save(const QString &filename) const writer.writeStartElement(QStringLiteral("streamcache")); + writer.writeAttribute(QStringLiteral("version"), QString::number(kFootageMetaVersion)); + writer.writeTextElement(QStringLiteral("decoder"), decoder_); writer.writeStartElement(QStringLiteral("streams")); diff --git a/app/node/project/footage/footagedescription.h b/app/node/project/footage/footagedescription.h index b8009f6fc..88c219195 100644 --- a/app/node/project/footage/footagedescription.h +++ b/app/node/project/footage/footagedescription.h @@ -112,6 +112,8 @@ public: } private: + static constexpr unsigned kFootageMetaVersion = 1; + QString decoder_; QVector video_streams_;