disable avatar DB log cleanup UI and functionality

This commit is contained in:
pa
2026-03-17 21:53:07 +09:00
parent ded9ce6da2
commit 1a16a2116a
5 changed files with 168 additions and 152 deletions
+2 -1
View File
@@ -839,7 +839,8 @@ export const useAuthStore = defineStore('Auth', () => {
*/
async function loginComplete() {
await database.initUserTables(userStore.currentUser.id);
advancedSettingsStore.runAvatarAutoCleanup(userStore.currentUser.id);
// [Disabled] Avatar DB log auto-cleanup on login
// advancedSettingsStore.runAvatarAutoCleanup(userStore.currentUser.id);
watchState.isLoggedIn = true;
AppApi.CheckGameRunning(); // restore state from hot-reload
}
+99 -95
View File
@@ -529,100 +529,103 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
);
}
async function setAvatarAutoCleanup(value) {
avatarAutoCleanup.value = value;
await configRepository.setString('VRCX_avatarAutoCleanup', value);
}
// [Disabled] Avatar DB log cleanup - setAvatarAutoCleanup
// 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.
*/
async function purgeAvatarFeedData(days) {
let cutoffDate = null;
if (days !== null) {
const cutoff = new Date();
cutoff.setDate(cutoff.getDate() - days);
cutoffDate = cutoff.toJSON();
}
// /**
// * @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;
// }
// }
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.
*/
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.
// */
// [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);
// }
// }
async function setSaveInstanceEmoji() {
saveInstanceEmoji.value = !saveInstanceEmoji.value;
@@ -1171,9 +1174,10 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
setProgressPieFilter,
setShowConfirmationOnSwitchAvatar,
setGameLogDisabled,
setAvatarAutoCleanup,
purgeAvatarFeedData,
runAvatarAutoCleanup,
// [Disabled] Avatar DB log cleanup exports
// setAvatarAutoCleanup,
// purgeAvatarFeedData,
// runAvatarAutoCleanup,
setUGCFolderPath,
cropPrintsChanged,
setAutoDeleteOldPrints,