mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
uncommit changes related to Avatar DB log cleanup feature
This commit is contained in:
+1
-2
@@ -839,8 +839,7 @@ export const useAuthStore = defineStore('Auth', () => {
|
||||
*/
|
||||
async function loginComplete() {
|
||||
await database.initUserTables(userStore.currentUser.id);
|
||||
// [Disabled] Avatar DB log auto-cleanup on login
|
||||
// advancedSettingsStore.runAvatarAutoCleanup(userStore.currentUser.id);
|
||||
advancedSettingsStore.runAvatarAutoCleanup(userStore.currentUser.id);
|
||||
watchState.isLoggedIn = true;
|
||||
AppApi.CheckGameRunning(); // restore state from hot-reload
|
||||
}
|
||||
|
||||
@@ -529,103 +529,100 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
|
||||
);
|
||||
}
|
||||
|
||||
// [Disabled] Avatar DB log cleanup - setAvatarAutoCleanup
|
||||
// async function setAvatarAutoCleanup(value) {
|
||||
// avatarAutoCleanup.value = value;
|
||||
// await configRepository.setString('VRCX_avatarAutoCleanup', value);
|
||||
// }
|
||||
async function setAvatarAutoCleanup(value) {
|
||||
avatarAutoCleanup.value = value;
|
||||
await configRepository.setString('VRCX_avatarAutoCleanup', value);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @param {number|null} days - Number of days to keep. Null means delete all.
|
||||
// */
|
||||
// [Disabled] Avatar DB log cleanup - purgeAvatarFeedData
|
||||
// async function purgeAvatarFeedData(days) {
|
||||
// let cutoffDate = null;
|
||||
// if (days !== null) {
|
||||
// const cutoff = new Date();
|
||||
// cutoff.setDate(cutoff.getDate() - days);
|
||||
// cutoffDate = cutoff.toJSON();
|
||||
// }
|
||||
//
|
||||
// purgeInProgress.value = true;
|
||||
// const msgBox = toast.warning(
|
||||
// t(
|
||||
// 'view.settings.advanced.advanced.database_cleanup.purge_in_progress'
|
||||
// ),
|
||||
// { duration: Infinity }
|
||||
// );
|
||||
//
|
||||
// try {
|
||||
// await database.purgeAvatarFeedData(cutoffDate);
|
||||
// await database.vacuum();
|
||||
// toast.dismiss(msgBox);
|
||||
// toast.success(
|
||||
// t(
|
||||
// 'view.settings.advanced.advanced.database_cleanup.purge_complete'
|
||||
// )
|
||||
// );
|
||||
// // Brief delay before restart to show success message
|
||||
// await new Promise((resolve) =>
|
||||
// setTimeout(resolve, 1500)
|
||||
// );
|
||||
// VRCXUpdaterStore.restartVRCX(false);
|
||||
// } catch (err) {
|
||||
// console.error(err);
|
||||
// toast.dismiss(msgBox);
|
||||
// toast.error(t('view.settings.advanced.advanced.database_cleanup.purge_failed', { error: err }));
|
||||
// } finally {
|
||||
// purgeInProgress.value = false;
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* @param {number|null} days - Number of days to keep. Null means delete all.
|
||||
*/
|
||||
async function purgeAvatarFeedData(days) {
|
||||
let cutoffDate = null;
|
||||
if (days !== null) {
|
||||
const cutoff = new Date();
|
||||
cutoff.setDate(cutoff.getDate() - days);
|
||||
cutoffDate = cutoff.toJSON();
|
||||
}
|
||||
|
||||
purgeInProgress.value = true;
|
||||
const msgBox = toast.warning(
|
||||
t(
|
||||
'view.settings.advanced.advanced.database_cleanup.purge_in_progress'
|
||||
),
|
||||
{ duration: Infinity }
|
||||
);
|
||||
|
||||
try {
|
||||
await database.purgeAvatarFeedData(cutoffDate);
|
||||
await database.vacuum();
|
||||
toast.dismiss(msgBox);
|
||||
toast.success(
|
||||
t(
|
||||
'view.settings.advanced.advanced.database_cleanup.purge_complete'
|
||||
)
|
||||
);
|
||||
// Brief delay before restart to show success message
|
||||
await new Promise((resolve) =>
|
||||
setTimeout(resolve, 1500)
|
||||
);
|
||||
VRCXUpdaterStore.restartVRCX(false);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
toast.dismiss(msgBox);
|
||||
toast.error(t('view.settings.advanced.advanced.database_cleanup.purge_failed', { error: err }));
|
||||
} finally {
|
||||
purgeInProgress.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Run auto-cleanup on startup if configured and enough time has passed.
|
||||
// * Reads config directly from configRepository to avoid race condition
|
||||
// * with initAdvancedSettings not having completed yet.
|
||||
// * @param {string} userId - Current user ID for per-user cleanup tracking.
|
||||
// */
|
||||
// [Disabled] Avatar DB log cleanup - runAvatarAutoCleanup
|
||||
// async function runAvatarAutoCleanup(userId) {
|
||||
// const cleanupSetting = await configRepository.getString(
|
||||
// 'VRCX_avatarAutoCleanup',
|
||||
// 'Off'
|
||||
// );
|
||||
// if (cleanupSetting === 'Off') return;
|
||||
//
|
||||
// const configKey = `VRCX_lastAvatarCleanupDate_${userId}`;
|
||||
// const lastCleanupStr = await configRepository.getString(
|
||||
// configKey,
|
||||
// ''
|
||||
// );
|
||||
// const now = new Date();
|
||||
//
|
||||
// if (lastCleanupStr) {
|
||||
// const lastCleanup = new Date(lastCleanupStr);
|
||||
// const daysSinceLastCleanup =
|
||||
// (now - lastCleanup) / (1000 * 60 * 60 * 24);
|
||||
// if (daysSinceLastCleanup < 7) return;
|
||||
// }
|
||||
//
|
||||
// const days = parseInt(cleanupSetting, 10);
|
||||
// if (isNaN(days) || days <= 0) return;
|
||||
//
|
||||
// const cutoff = new Date();
|
||||
// cutoff.setDate(cutoff.getDate() - days);
|
||||
// const cutoffDate = cutoff.toJSON();
|
||||
//
|
||||
// try {
|
||||
// await database.purgeAvatarFeedData(cutoffDate);
|
||||
// await configRepository.setString(
|
||||
// configKey,
|
||||
// now.toJSON()
|
||||
// );
|
||||
// console.log(
|
||||
// `Auto-cleaned avatar feed data older than ${days} days`
|
||||
// );
|
||||
// } catch (err) {
|
||||
// console.error('Avatar auto-cleanup failed:', err);
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* Run auto-cleanup on startup if configured and enough time has passed.
|
||||
* Reads config directly from configRepository to avoid race condition
|
||||
* with initAdvancedSettings not having completed yet.
|
||||
* @param {string} userId - Current user ID for per-user cleanup tracking.
|
||||
*/
|
||||
async function runAvatarAutoCleanup(userId) {
|
||||
const cleanupSetting = await configRepository.getString(
|
||||
'VRCX_avatarAutoCleanup',
|
||||
'Off'
|
||||
);
|
||||
if (cleanupSetting === 'Off') return;
|
||||
|
||||
const configKey = `VRCX_lastAvatarCleanupDate_${userId}`;
|
||||
const lastCleanupStr = await configRepository.getString(
|
||||
configKey,
|
||||
''
|
||||
);
|
||||
const now = new Date();
|
||||
|
||||
if (lastCleanupStr) {
|
||||
const lastCleanup = new Date(lastCleanupStr);
|
||||
const daysSinceLastCleanup =
|
||||
(now - lastCleanup) / (1000 * 60 * 60 * 24);
|
||||
if (daysSinceLastCleanup < 7) return;
|
||||
}
|
||||
|
||||
const days = parseInt(cleanupSetting, 10);
|
||||
if (isNaN(days) || days <= 0) return;
|
||||
|
||||
const cutoff = new Date();
|
||||
cutoff.setDate(cutoff.getDate() - days);
|
||||
const cutoffDate = cutoff.toJSON();
|
||||
|
||||
try {
|
||||
await database.purgeAvatarFeedData(cutoffDate);
|
||||
await configRepository.setString(
|
||||
configKey,
|
||||
now.toJSON()
|
||||
);
|
||||
console.log(
|
||||
`Auto-cleaned avatar feed data older than ${days} days`
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Avatar auto-cleanup failed:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function setSaveInstanceEmoji() {
|
||||
saveInstanceEmoji.value = !saveInstanceEmoji.value;
|
||||
@@ -1174,10 +1171,9 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
|
||||
setProgressPieFilter,
|
||||
setShowConfirmationOnSwitchAvatar,
|
||||
setGameLogDisabled,
|
||||
// [Disabled] Avatar DB log cleanup exports
|
||||
// setAvatarAutoCleanup,
|
||||
// purgeAvatarFeedData,
|
||||
// runAvatarAutoCleanup,
|
||||
setAvatarAutoCleanup,
|
||||
purgeAvatarFeedData,
|
||||
runAvatarAutoCleanup,
|
||||
setUGCFolderPath,
|
||||
cropPrintsChanged,
|
||||
setAutoDeleteOldPrints,
|
||||
|
||||
Reference in New Issue
Block a user