diff --git a/res/schema.xml b/res/schema.xml index 421b70ccdd9..1bd7acc3c63 100644 --- a/res/schema.xml +++ b/res/schema.xml @@ -574,4 +574,12 @@ reapplying those migrations. UPDATE library SET source_synchronized_ms=NULL WHERE source_synchronized_ms=0; + + + Replace file type "aif" with "aiff". + + + UPDATE library SET filetype='aiff' WHERE filetype='aif'; + + diff --git a/src/database/mixxxdb.cpp b/src/database/mixxxdb.cpp index 34d6b66b98f..af053a10a9a 100644 --- a/src/database/mixxxdb.cpp +++ b/src/database/mixxxdb.cpp @@ -12,7 +12,7 @@ const QString MixxxDb::kDefaultSchemaFile(":/schema.xml"); //static -const int MixxxDb::kRequiredSchemaVersion = 38; +const int MixxxDb::kRequiredSchemaVersion = 39; namespace { diff --git a/src/sources/soundsource.cpp b/src/sources/soundsource.cpp index cd20e0af213..b393fc1cf35 100644 --- a/src/sources/soundsource.cpp +++ b/src/sources/soundsource.cpp @@ -28,6 +28,10 @@ inline QString fileTypeFromSuffix(const QString& suffix) { // of an empty string which might either be null or "". return QString{}; } + // Map shortened suffix "aif" to "aiff" for disambiguation + if (fileType == QStringLiteral("aif")) { + return QStringLiteral("aiff"); + } return fileType; } diff --git a/src/test/soundproxy_test.cpp b/src/test/soundproxy_test.cpp index e0cc81e7eb5..2c2c27b4aa0 100644 --- a/src/test/soundproxy_test.cpp +++ b/src/test/soundproxy_test.cpp @@ -752,8 +752,10 @@ TEST_F(SoundSourceProxyTest, getTypeFromFile) { } TEST_F(SoundSourceProxyTest, getTypeFromMissingFile) { + // Also verify that the shortened suffix ".aif" (case-insensitive) is + // mapped to file type "aiff", independent of whether the file exists or not! const QFileInfo missingFileWithUppercaseSuffixAndLeadingTrailingWhitespaceSuffix = - kTestDir.absoluteFilePath(QStringLiteral("missing_file. AIFF ")); + kTestDir.absoluteFilePath(QStringLiteral("missing_file. AIF ")); ASSERT_FALSE(missingFileWithUppercaseSuffixAndLeadingTrailingWhitespaceSuffix.exists()); @@ -761,3 +763,22 @@ TEST_F(SoundSourceProxyTest, getTypeFromMissingFile) { qPrintable(mixxx::SoundSource::getTypeFromFile( missingFileWithUppercaseSuffixAndLeadingTrailingWhitespaceSuffix))); } + +TEST_F(SoundSourceProxyTest, getTypeFromAiffFile) { + const QString aiffFilePath = + kTestDir.absoluteFilePath(QStringLiteral("cover-test.aiff")); + + ASSERT_TRUE(QFileInfo::exists(aiffFilePath)); + ASSERT_STREQ(qPrintable("aiff"), + qPrintable(mixxx::SoundSource::getTypeFromFile( + aiffFilePath))); + + const QString aiffFilePathWithShortenedSuffix = + mixxxtest::generateTemporaryFileName(QStringLiteral("cover-test.aif")); + mixxxtest::copyFile(aiffFilePath, aiffFilePathWithShortenedSuffix); + ASSERT_TRUE(QFileInfo::exists(aiffFilePathWithShortenedSuffix)); + + EXPECT_STREQ(qPrintable("aiff"), + qPrintable(mixxx::SoundSource::getTypeFromFile( + aiffFilePathWithShortenedSuffix))); +}