1 Commits

Author SHA1 Message Date
Dmitry Vedenko
d74083ba4b Do not fail if user_version pragma is invalid
In most of the cases seen so far, if the user_version pragma is
 invalid it means that it was corrupted on disk.
2023-03-31 12:56:03 +03:00
5 changed files with 19 additions and 29 deletions

View File

@@ -38,7 +38,7 @@ jobs:
#cache-dependency-path: # optional
- uses: BSFishy/pip-action@v1
with:
packages: conan
packages: conan==1.59.0
- name: Cache for .conan
id: cache-conan
uses: actions/cache@v2

View File

@@ -166,7 +166,7 @@ set(CPACK_PACKAGE_NAME "audacity-project-tools")
set(CPACK_PACKAGE_VENDOR "Audacity")
set(CPACK_PACKAGE_VERSION_MAJOR 1)
set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 2)
set(CPACK_PACKAGE_VERSION_PATCH 3)
set(CPACK_GENERATOR ZIP)
SET(CPACK_OUTPUT_FILE_PREFIX packages)

View File

@@ -48,4 +48,4 @@ $ ls
`audacity-project-tools` requires a C++17 compliant compiler with the complete C++17 library. The build requires <filesystem> and floating-point versions of `from_chars`.
CMake and Conan are required to configure the project.
CMake and Conan are required to configure the project. Conan 2.0 is not supported ATM.

View File

@@ -1,21 +1 @@
bottle==0.12.19
certifi==2021.10.8
charset-normalizer==2.0.9
colorama==0.4.4
conan==1.43.2
distro==1.6.0
fasteners==0.16.3
idna==3.3
Jinja2==2.11.3
MarkupSafe==2.0.1
node-semver==0.6.1
patch-ng==1.17.4
pluginbase==1.0.1
Pygments==2.10.0
PyJWT==1.7.1
python-dateutil==2.8.2
PyYAML==5.4.1
requests==2.26.0
six==1.16.0
tqdm==4.62.3
urllib3==1.26.7
conan==1.59.0

View File

@@ -25,7 +25,7 @@ namespace
constexpr int64_t AudacityProjectID = 1096107097;
constexpr int64_t MaxSupportedVersion =
(3 << 24) + (1 << 16) + (3 << 8) + 0; // 3.1.3.0
(3 << 24) + (3 << 16) + (0 << 8) + 0; // 3.3.0.0
template<typename T> size_t readInt(const std::string& string, size_t offset, T& output)
{
@@ -112,13 +112,23 @@ AudacityDatabase::AudacityDatabase(
mProjectVersion =
mDatabase->execAndGet("PRAGMA user_version;").getUInt();
const auto majorVersion = (mProjectVersion >> 24) & 0xFF;
const auto minorVersion = (mProjectVersion >> 16) & 0xFF;
const auto patchVersion = (mProjectVersion >> 8) & 0xFF;
fmt::print(
"Project requires Audacity {}.{}.{}\n",
(mProjectVersion >> 24) & 0xFF, (mProjectVersion >> 16) & 0xFF,
(mProjectVersion >> 8) & 0xFF);
"Project requires Audacity {}.{}.{}\n", majorVersion,
minorVersion, patchVersion);
if (majorVersion != 3)
{
fmt::print("user_version pragma appears to be broken...\n");
mProjectVersion = MaxSupportedVersion;
}
if (mProjectVersion > MaxSupportedVersion)
throw std::runtime_error("Unsupported project version");
fmt::print(
"DANGER!!! Unsupported Audacity version detected! Project data might be lost! Proceed with caution!\n");
}, true);
}