forked from didirus/AstralRinth
Compare commits
10 Commits
AR-0.10.3
...
AR-0.10.30
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ecb20afd6 | |||
| 1e10f24efe | |||
| 006fd7c7f5 | |||
| 1e8e001eb8 | |||
| 585935c799 | |||
| a64c3360d2 | |||
| a2b2711204 | |||
| ab57926e44 | |||
| 35cd79727a | |||
|
|
c47bcf665d |
51
.github/workflows/astralrinth-build.yml
vendored
51
.github/workflows/astralrinth-build.yml
vendored
@@ -23,12 +23,13 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [macos-latest, windows-latest, ubuntu-latest]
|
||||
# platform: [macos-latest, windows-latest, ubuntu-latest]
|
||||
platform: [ubuntu-latest]
|
||||
include:
|
||||
- platform: macos-latest
|
||||
artifact-target-name: universal-apple-darwin
|
||||
- platform: windows-latest
|
||||
artifact-target-name: x86_64-pc-windows-msvc
|
||||
# - platform: macos-latest
|
||||
# artifact-target-name: universal-apple-darwin
|
||||
# - platform: windows-latest
|
||||
# artifact-target-name: x86_64-pc-windows-msvc
|
||||
- platform: ubuntu-latest
|
||||
artifact-target-name: x86_64-unknown-linux-gnu
|
||||
|
||||
@@ -72,11 +73,11 @@ jobs:
|
||||
- name: 🧰 Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: ✍️ Set up Windows code signing (jsign)
|
||||
if: matrix.platform == 'windows' && env.SIGN_WINDOWS_BINARIES == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
choco install jsign --ignore-dependencies
|
||||
# - name: ✍️ Set up Windows code signing (jsign)
|
||||
# if: matrix.platform == 'windows-latest' && env.SIGN_WINDOWS_BINARIES == 'true'
|
||||
# shell: bash
|
||||
# run: |
|
||||
# choco install jsign --ignore-dependencies
|
||||
|
||||
- name: 🗑️ Clean up cached bundles
|
||||
shell: bash
|
||||
@@ -84,12 +85,12 @@ jobs:
|
||||
rm -rf target/release/bundle
|
||||
rm -rf target/*/release/bundle || true
|
||||
|
||||
- name: 🔨 Build macOS app
|
||||
if: matrix.platform == 'macos-latest'
|
||||
run: pnpm --filter=@modrinth/app run tauri build --target universal-apple-darwin --config tauri-release.conf.json
|
||||
env:
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||
# - name: 🔨 Build macOS app
|
||||
# if: matrix.platform == 'macos-latest'
|
||||
# run: pnpm --filter=@modrinth/app run tauri build --target universal-apple-darwin --config tauri-release.conf.json
|
||||
# env:
|
||||
# TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||
|
||||
- name: 🔨 Build Linux app
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
@@ -98,15 +99,15 @@ jobs:
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||
|
||||
- name: 🔨 Build Windows app
|
||||
if: matrix.platform == 'windows-latest'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$env:JAVA_HOME = "$env:JAVA_HOME_11_X64"
|
||||
pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json --verbose --bundles 'nsis'
|
||||
env:
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||
# - name: 🔨 Build Windows app
|
||||
# if: matrix.platform == 'windows-latest'
|
||||
# shell: pwsh
|
||||
# run: |
|
||||
# $env:JAVA_HOME = "$env:JAVA_HOME_11_X64"
|
||||
# pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json --verbose --bundles 'nsis'
|
||||
# env:
|
||||
# TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||
|
||||
- name: 📤 Upload app bundles
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</div>
|
||||
<div v-if="updateState">
|
||||
<a>
|
||||
<Button class="download" :disabled="installState" @click="confirmUpdating(), getRemote(false, false)">
|
||||
<Button class="download" :disabled="installState" @click="initUpdateModal(), getRemote(false)">
|
||||
<DownloadIcon />
|
||||
{{
|
||||
installState
|
||||
@@ -48,7 +48,7 @@
|
||||
</Button>
|
||||
</a>
|
||||
</div>
|
||||
<ModalWrapper ref="confirmUpdate" :has-to-type="false" header="Request to update the AstralRinth launcher">
|
||||
<ModalWrapper ref="updateModalView" :has-to-type="false" header="Request to update the AstralRinth launcher">
|
||||
<div class="modal-body">
|
||||
<div class="markdown-body">
|
||||
<p>The new version of the AstralRinth launcher is available.</p>
|
||||
@@ -66,14 +66,30 @@
|
||||
<p class="cosmic inline-fix">v{{ version }}</p>
|
||||
</span>
|
||||
<div class="button-group push-right">
|
||||
<Button class="download-modal" @click="confirmUpdate.hide()">
|
||||
Decline</Button>
|
||||
<Button class="download-modal" @click="approveUpdate()">
|
||||
Accept
|
||||
<Button class="updater-modal" @click="updateModalView.hide()">
|
||||
Cancel</Button>
|
||||
<Button class="updater-modal" @click="initDownload()">
|
||||
Download file
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</ModalWrapper>
|
||||
<ModalWrapper ref="updateRequestFailView" :has-to-type="false" header="Failed to request a file from the server :(">
|
||||
<div class="modal-body">
|
||||
<div class="markdown-body">
|
||||
<p><strong>Error occurred</strong></p>
|
||||
<p>Unfortunately, the program was unable to download the file from our servers.</p>
|
||||
<p>Please try downloading it yourself from <a href="https://me.astralium.su/get/ar" target="_blank" rel="noopener noreferrer">Git Astralium</a> if there are any updates available.</p>
|
||||
</div>
|
||||
<span>Local AstralRinth •
|
||||
<p class="cosmic inline-fix">v{{ version }}</p>
|
||||
</span>
|
||||
</div>
|
||||
<div class="button-group push-right">
|
||||
<Button class="updater-modal" @click="updateRequestFailView.hide()">
|
||||
Close</Button>
|
||||
</div>
|
||||
</ModalWrapper>
|
||||
</div>
|
||||
<transition name="download">
|
||||
<Card v-if="showCard === true && currentLoadingBars.length > 0" ref="card" class="info-card">
|
||||
@@ -129,18 +145,22 @@ const version = await getVersion()
|
||||
import { installState, getRemote, updateState } from '@/helpers/update.js'
|
||||
import ModalWrapper from './modal/ModalWrapper.vue'
|
||||
|
||||
const confirmUpdate = ref(null)
|
||||
const updateModalView = ref(null)
|
||||
const updateRequestFailView = ref(null)
|
||||
|
||||
const confirmUpdating = async () => {
|
||||
confirmUpdate.value.show()
|
||||
const initUpdateModal = async () => {
|
||||
updateModalView.value.show()
|
||||
}
|
||||
|
||||
const approveUpdate = async () => {
|
||||
confirmUpdate.value.hide()
|
||||
await getRemote(true, true)
|
||||
const initDownload = async () => {
|
||||
updateModalView.value.hide()
|
||||
const result = await getRemote(true);
|
||||
if (!result) {
|
||||
updateRequestFailView.value.show()
|
||||
}
|
||||
}
|
||||
|
||||
await getRemote(true, false)
|
||||
await getRemote(false)
|
||||
|
||||
const router = useRouter()
|
||||
const card = ref(null)
|
||||
@@ -375,7 +395,7 @@ onBeforeUnmount(() => {
|
||||
text-shadow: #26065e;
|
||||
}
|
||||
|
||||
.download-modal {
|
||||
.updater-modal {
|
||||
color: #3e8cde;
|
||||
padding: var(--gap-sm) var(--gap-lg);
|
||||
text-decoration: none;
|
||||
@@ -386,9 +406,9 @@ onBeforeUnmount(() => {
|
||||
transition: color 0.35s ease;
|
||||
}
|
||||
|
||||
.download-modal:hover,
|
||||
.download-modal:focus,
|
||||
.download-modal:active {
|
||||
.updater-modal:hover,
|
||||
.updater-modal:focus,
|
||||
.updater-modal:active {
|
||||
color: #10fae5;
|
||||
text-shadow: #26065e;
|
||||
}
|
||||
|
||||
@@ -2,21 +2,19 @@ import { ref } from 'vue'
|
||||
import { getVersion } from '@tauri-apps/api/app'
|
||||
import { getArtifact, getOS } from '@/helpers/utils.js'
|
||||
|
||||
|
||||
export const allowState = ref(false)
|
||||
export const installState = ref(false)
|
||||
export const updateState = ref(false)
|
||||
export const latestBetaCommitTruncatedSha = ref('')
|
||||
export const latestBetaCommitLink = ref('')
|
||||
export const launcherUrl = 'https://www.astralium.su/get/ar'
|
||||
|
||||
const os = ref('')
|
||||
const currentOS = ref('')
|
||||
const releaseLink = `https://git.astralium.su/api/v1/repos/didirus/AstralRinth/releases/latest`
|
||||
const failedFetch = [`Failed to fetch remote releases:`, `Failed to fetch remote commits:`]
|
||||
const osNames = ['macos', 'windows', 'linux']
|
||||
const macExtension = `.dmg` // MacOS file type for download
|
||||
const windowsExtension = `.msi` // Windows file type for download
|
||||
const blacklistedBuilds = [
|
||||
|
||||
const osList = ['macos', 'windows', 'linux']
|
||||
const macExtensionList = ['.app', '.dmg']
|
||||
const windowsExtensionList = ['.exe', '.msi']
|
||||
|
||||
const blacklistPrefixes = [
|
||||
`dev`,
|
||||
`nightly`,
|
||||
`dirty`,
|
||||
@@ -26,110 +24,73 @@ const blacklistedBuilds = [
|
||||
`dirty_nightly`,
|
||||
] // This is blacklisted builds for download. For example, file.startsWith('dev') is not allowed.
|
||||
|
||||
/**
|
||||
* Asynchronous function to get remote data and handle updates and downloads.
|
||||
*
|
||||
* @param {boolean} elementIdBool - Indicates whether to disable an element ID.
|
||||
* @param {boolean} downloadArtifactBool - Indicates whether to download an artifact.
|
||||
*/
|
||||
export async function getRemote(elementIdBool, downloadArtifactBool) {
|
||||
fetch(releaseLink)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(response.status)
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.then(async (data) => {
|
||||
os.value = await getOS()
|
||||
const latestRelease = data.name
|
||||
let remoteVersion = undefined
|
||||
export async function getRemote(isDownloadState) {
|
||||
var releaseData = null;
|
||||
var result = false;
|
||||
try {
|
||||
const response = await fetch(releaseLink);
|
||||
if (!response.ok) {
|
||||
throw new Error(response.status);
|
||||
}
|
||||
const remoteData = await response.json();
|
||||
currentOS.value = await getOS();
|
||||
const remoteLatestReleaseTag = remoteData.tag_name;
|
||||
releaseData = document.getElementById('releaseData');
|
||||
const remoteVersion = releaseData ? (releaseData.textContent = remoteLatestReleaseTag) : remoteLatestReleaseTag;
|
||||
|
||||
if (!elementIdBool) {
|
||||
const releaseData = document.getElementById('releaseData')
|
||||
if (releaseData == null) {
|
||||
console.error('Release data element not found.')
|
||||
return false
|
||||
}
|
||||
releaseData.textContent = latestRelease
|
||||
remoteVersion = `${releaseData.textContent}`
|
||||
} else {
|
||||
remoteVersion = latestRelease
|
||||
}
|
||||
if (osNames.includes(os.value.toLowerCase())) {
|
||||
if (remoteVersion.startsWith('v' + await getVersion())) {
|
||||
updateState.value = false
|
||||
allowState.value = false
|
||||
} else {
|
||||
updateState.value = true
|
||||
allowState.value = true
|
||||
}
|
||||
} else {
|
||||
updateState.value = false
|
||||
allowState.value = false
|
||||
}
|
||||
console.log('Update available state is', updateState.value)
|
||||
console.log('Remote version is', remoteVersion)
|
||||
console.log('Local version is', await getVersion())
|
||||
console.log('Operating System is', os.value)
|
||||
if (osList.includes(currentOS.value.toLowerCase())) {
|
||||
const localVersion = await getVersion();
|
||||
const isUpdateAvailable = !remoteVersion.includes(localVersion);
|
||||
|
||||
if (downloadArtifactBool) {
|
||||
installState.value = true
|
||||
const builds = data.assets
|
||||
const fileName = getInstaller(getExtension(), builds)
|
||||
if (fileName != null) {
|
||||
await getArtifact(fileName[1], fileName[0], os.value, true)
|
||||
}
|
||||
installState.value = false
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(failedFetch[0], error)
|
||||
if (!elementIdBool) {
|
||||
const errorData = document.getElementById('releaseData')
|
||||
if (errorData) {
|
||||
errorData.textContent = `${error.message}`
|
||||
}
|
||||
updateState.value = false
|
||||
allowState.value = false
|
||||
installState.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
updateState.value = isUpdateAvailable;
|
||||
allowState.value = isUpdateAvailable;
|
||||
} else {
|
||||
updateState.value = false;
|
||||
allowState.value = false;
|
||||
}
|
||||
if (isDownloadState) {
|
||||
installState.value = true;
|
||||
const builds = remoteData.assets;
|
||||
const fileName = getInstaller(getExtension(), builds);
|
||||
result = fileName ? await getArtifact(fileName[1], fileName[0], currentOS.value, true) : false;
|
||||
installState.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the installer for a specific operating system.
|
||||
*
|
||||
* @param {string} osExtension - The file extension of the installer.
|
||||
* @param {Array} builds - The list of builds.
|
||||
* @return {Array|null} An array containing the installer name and URL if found, or null if not found.
|
||||
*/
|
||||
function getInstaller(osExtension, builds) {
|
||||
for (let i of builds) {
|
||||
let blacklistedItem = false
|
||||
blacklistedBuilds.forEach((item) => {
|
||||
if (i.name.startsWith(item)) {
|
||||
return (blacklistedItem = true)
|
||||
console.log('Update available state is', updateState.value);
|
||||
console.log('Remote version is', remoteVersion);
|
||||
console.log('Local version is', await getVersion());
|
||||
console.log('Operating System is', currentOS.value);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error(failedFetch[0], error);
|
||||
if (!releaseData) {
|
||||
const errorData = document.getElementById('releaseData');
|
||||
if (errorData) {
|
||||
errorData.textContent = `${error.message}`;
|
||||
}
|
||||
})
|
||||
if (i.name.endsWith(osExtension) && !blacklistedItem) {
|
||||
console.log(i.browser_download_url)
|
||||
return [i.name, i.browser_download_url]
|
||||
updateState.value = false;
|
||||
allowState.value = false;
|
||||
installState.value = false;
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* A function to get the extension based on the operating system.
|
||||
*
|
||||
* @return {string} The extension based on the operating system.
|
||||
*/
|
||||
function getExtension() {
|
||||
if (os.value.toLowerCase() == osNames[0]) {
|
||||
return macExtension
|
||||
} else if (os.value.toLowerCase() == osNames[1]) {
|
||||
return windowsExtension
|
||||
function getInstaller(osExtension, builds) {
|
||||
console.log(osExtension, builds)
|
||||
for (const build of builds) {
|
||||
if (blacklistPrefixes.some(prefix => build.name.startsWith(prefix))) {
|
||||
continue;
|
||||
}
|
||||
if (osExtension.some(ext => build.name.endsWith(ext))) {
|
||||
console.log(build.name, build.browser_download_url);
|
||||
return [build.name, build.browser_download_url];
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function getExtension() {
|
||||
return osList.find(osName => osName === currentOS.value.toLowerCase())?.endsWith('macos')
|
||||
? macExtensionList
|
||||
: windowsExtensionList;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
|
||||
// let update_fut = updater.check();
|
||||
|
||||
// tracing::info!("Initializing app state...");
|
||||
State::init().await?;
|
||||
|
||||
// let check_bar = theseus::init_loading(
|
||||
// theseus::LoadingBarType::CheckingForUpdates,
|
||||
// 1.0,
|
||||
@@ -87,7 +84,7 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
// #[cfg(not(feature = "updater"))]
|
||||
// {
|
||||
// }
|
||||
|
||||
tracing::info!("Initializing app state...");
|
||||
State::init().await?;
|
||||
tracing::info!("AstralRinth state successfully initialized.");
|
||||
let state = State::get().await?;
|
||||
@@ -164,10 +161,10 @@ fn main() {
|
||||
|
||||
let mut builder = tauri::Builder::default();
|
||||
|
||||
#[cfg(feature = "updater")]
|
||||
{
|
||||
builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
|
||||
}
|
||||
// #[cfg(feature = "updater")]
|
||||
// {
|
||||
// builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
|
||||
// }
|
||||
|
||||
builder = builder
|
||||
.plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
]
|
||||
},
|
||||
"productName": "AstralRinth App",
|
||||
"version": "0.10.3",
|
||||
"version": "0.10.302",
|
||||
"mainBinaryName": "AstralRinth App",
|
||||
"identifier": "AstralRinthApp",
|
||||
"plugins": {
|
||||
|
||||
@@ -123,6 +123,7 @@ public final class MinecraftLaunch {
|
||||
setAccessible0.setAccessible(true);
|
||||
setAccessible0.invoke(object, true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
object.setAccessible(true);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ use sqlx::sqlite::{
|
||||
SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions,
|
||||
};
|
||||
use sqlx::{Pool, Sqlite};
|
||||
use tokio::time::Instant;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -17,8 +18,10 @@ pub(crate) async fn connect() -> crate::Result<Pool<Sqlite>> {
|
||||
crate::util::io::create_dir_all(&settings_dir).await?;
|
||||
}
|
||||
|
||||
let uri = format!("sqlite:{}", settings_dir.join("app.db").display());
|
||||
let db_path = settings_dir.join("app.db");
|
||||
let db_exists = db_path.exists();
|
||||
|
||||
let uri = format!("sqlite:{}", db_path.display());
|
||||
let conn_options = SqliteConnectOptions::from_str(&uri)?
|
||||
.busy_timeout(Duration::from_secs(30))
|
||||
.journal_mode(SqliteJournalMode::Wal)
|
||||
@@ -30,8 +33,16 @@ pub(crate) async fn connect() -> crate::Result<Pool<Sqlite>> {
|
||||
.connect_with(conn_options)
|
||||
.await?;
|
||||
|
||||
if db_exists {
|
||||
fix_modrinth_issued_migrations(&pool).await?;
|
||||
}
|
||||
|
||||
sqlx::migrate!().run(&pool).await?;
|
||||
|
||||
if !db_exists {
|
||||
fix_modrinth_issued_migrations(&pool).await?;
|
||||
}
|
||||
|
||||
if let Err(err) = stale_data_cleanup(&pool).await {
|
||||
tracing::warn!(
|
||||
"Failed to clean up stale data from state database: {err}"
|
||||
@@ -62,3 +73,63 @@ async fn stale_data_cleanup(pool: &Pool<Sqlite>) -> crate::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/*
|
||||
// Patch by AstralRinth - 08.07.2025
|
||||
Problem files:
|
||||
/packages/app-lib/migrations/20240711194701_init.sql !eol
|
||||
/packages/app-lib/migrations/20240813205023_drop-active-unique.sql !eol
|
||||
/packages/app-lib/migrations/20240930001852_disable-personalized-ads.sql !eol
|
||||
/packages/app-lib/migrations/20241222013857_feature-flags.sql !eol
|
||||
*/
|
||||
async fn fix_modrinth_issued_migrations(
|
||||
pool: &Pool<Sqlite>,
|
||||
) -> crate::Result<()> {
|
||||
let started = Instant::now();
|
||||
tracing::info!("Fixing modrinth issued migrations");
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE "_sqlx_migrations"
|
||||
SET checksum = X'e973512979feac07e415405291eefafc1ef0bd89454958ad66f5452c381db8679c20ffadab55194ecf6ba8ec4ca2db21'
|
||||
WHERE version = '20240711194701';
|
||||
"#,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
tracing::info!("⚙️ Fixed first migration");
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE "_sqlx_migrations"
|
||||
SET checksum = X'5b53534a7ffd74eebede234222be47e1d37bd0cc5fee4475212491b0c0379c16e3079e08eee0af959b1fa20835eeb206'
|
||||
WHERE version = '20240813205023';
|
||||
"#,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
tracing::info!("⚙️ Fixed second migration");
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE "_sqlx_migrations"
|
||||
SET checksum = X'c0de804f171b5530010edae087a6e75645c0e90177e28365f935c9fdd9a5c68e24850b8c1498e386a379d525d520bc57'
|
||||
WHERE version = '20240930001852';
|
||||
"#,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
tracing::info!("⚙️ Fixed third migration");
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE "_sqlx_migrations"
|
||||
SET checksum = X'c17542cb989a0466153e695bfa4717f8970feee185ca186a2caa1f2f6c5d4adb990ab97c26cacfbbe09c39ac81551704'
|
||||
WHERE version = '20241222013857';
|
||||
"#,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
tracing::info!("⚙️ Fixed fourth migration");
|
||||
let elapsed = started.elapsed();
|
||||
tracing::info!(
|
||||
"✅ Fixed all known modrinth-issued migrations in {:.2?}",
|
||||
elapsed
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
103
patches/db_migrations_fix.patch
Normal file
103
patches/db_migrations_fix.patch
Normal file
@@ -0,0 +1,103 @@
|
||||
diff --git a/packages/app-lib/src/state/db.rs b/packages/app-lib/src/state/db.rs
|
||||
index 14c53d81..607a345f 100644
|
||||
--- a/packages/app-lib/src/state/db.rs
|
||||
+++ b/packages/app-lib/src/state/db.rs
|
||||
@@ -3,6 +3,7 @@ use sqlx::sqlite::{
|
||||
SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions,
|
||||
};
|
||||
use sqlx::{Pool, Sqlite};
|
||||
+use tokio::time::Instant;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -17,8 +18,10 @@ pub(crate) async fn connect() -> crate::Result<Pool<Sqlite>> {
|
||||
crate::util::io::create_dir_all(&settings_dir).await?;
|
||||
}
|
||||
|
||||
- let uri = format!("sqlite:{}", settings_dir.join("app.db").display());
|
||||
+ let db_path = settings_dir.join("app.db");
|
||||
+ let db_exists = db_path.exists();
|
||||
|
||||
+ let uri = format!("sqlite:{}", db_path.display());
|
||||
let conn_options = SqliteConnectOptions::from_str(&uri)?
|
||||
.busy_timeout(Duration::from_secs(30))
|
||||
.journal_mode(SqliteJournalMode::Wal)
|
||||
@@ -30,10 +33,16 @@ pub(crate) async fn connect() -> crate::Result<Pool<Sqlite>> {
|
||||
.connect_with(conn_options)
|
||||
.await?;
|
||||
|
||||
- fix_migration_20240711194701(&pool).await?; // Patch by AstralRinth - 08.07.2025
|
||||
+ if db_exists {
|
||||
+ fix_modrinth_issued_migrations(&pool).await?;
|
||||
+ }
|
||||
|
||||
sqlx::migrate!().run(&pool).await?;
|
||||
|
||||
+ if !db_exists {
|
||||
+ fix_modrinth_issued_migrations(&pool).await?;
|
||||
+ }
|
||||
+
|
||||
if let Err(err) = stale_data_cleanup(&pool).await {
|
||||
tracing::warn!(
|
||||
"Failed to clean up stale data from state database: {err}"
|
||||
@@ -66,8 +75,17 @@ async fn stale_data_cleanup(pool: &Pool<Sqlite>) -> crate::Result<()> {
|
||||
}
|
||||
/*
|
||||
// Patch by AstralRinth - 08.07.2025
|
||||
+Problem files:
|
||||
+/packages/app-lib/migrations/20240711194701_init.sql !eol
|
||||
+/packages/app-lib/migrations/20240813205023_drop-active-unique.sql !eol
|
||||
+/packages/app-lib/migrations/20240930001852_disable-personalized-ads.sql !eol
|
||||
+/packages/app-lib/migrations/20241222013857_feature-flags.sql !eol
|
||||
*/
|
||||
-async fn fix_migration_20240711194701(pool: &Pool<Sqlite>) -> crate::Result<()> {
|
||||
+async fn fix_modrinth_issued_migrations(
|
||||
+ pool: &Pool<Sqlite>,
|
||||
+) -> crate::Result<()> {
|
||||
+ let started = Instant::now();
|
||||
+ tracing::info!("Fixing modrinth issued migrations");
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE "_sqlx_migrations"
|
||||
@@ -77,5 +95,41 @@ async fn fix_migration_20240711194701(pool: &Pool<Sqlite>) -> crate::Result<()>
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
+ tracing::info!("⚙️ Fixed first migration");
|
||||
+ sqlx::query(
|
||||
+ r#"
|
||||
+ UPDATE "_sqlx_migrations"
|
||||
+ SET checksum = X'5b53534a7ffd74eebede234222be47e1d37bd0cc5fee4475212491b0c0379c16e3079e08eee0af959b1fa20835eeb206'
|
||||
+ WHERE version = '20240813205023';
|
||||
+ "#,
|
||||
+ )
|
||||
+ .execute(pool)
|
||||
+ .await?;
|
||||
+ tracing::info!("⚙️ Fixed second migration");
|
||||
+ sqlx::query(
|
||||
+ r#"
|
||||
+ UPDATE "_sqlx_migrations"
|
||||
+ SET checksum = X'c0de804f171b5530010edae087a6e75645c0e90177e28365f935c9fdd9a5c68e24850b8c1498e386a379d525d520bc57'
|
||||
+ WHERE version = '20240930001852';
|
||||
+ "#,
|
||||
+ )
|
||||
+ .execute(pool)
|
||||
+ .await?;
|
||||
+ tracing::info!("⚙️ Fixed third migration");
|
||||
+ sqlx::query(
|
||||
+ r#"
|
||||
+ UPDATE "_sqlx_migrations"
|
||||
+ SET checksum = X'c17542cb989a0466153e695bfa4717f8970feee185ca186a2caa1f2f6c5d4adb990ab97c26cacfbbe09c39ac81551704'
|
||||
+ WHERE version = '20241222013857';
|
||||
+ "#,
|
||||
+ )
|
||||
+ .execute(pool)
|
||||
+ .await?;
|
||||
+ tracing::info!("⚙️ Fixed fourth migration");
|
||||
+ let elapsed = started.elapsed();
|
||||
+ tracing::info!(
|
||||
+ "✅ Fixed all known modrinth-issued migrations in {:.2?}",
|
||||
+ elapsed
|
||||
+ );
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user