VRC reg auto back every 3days

This commit is contained in:
Natsumi
2025-08-15 21:16:46 +12:00
parent ba763b9764
commit 9846c01b84
3 changed files with 19 additions and 10 deletions
+1 -1
View File
@@ -1554,7 +1554,7 @@
"name": "Name", "name": "Name",
"date": "Date", "date": "Date",
"action": "Action", "action": "Action",
"auto_backup": "Weekly Auto Backup", "auto_backup": "Auto backup every 3 days (deletes after 2 weeks)",
"restore_prompt": "VRCX has noticed auto backup of VRC registry settings is enabled but this computer doesn't have any, if you'd like to restore from backup you can do so from here." "restore_prompt": "VRCX has noticed auto backup of VRC registry settings is enabled but this computer doesn't have any, if you'd like to restore from backup you can do so from here."
}, },
"group_member_moderation": { "group_member_moderation": {
+1
View File
@@ -111,6 +111,7 @@ export const useUpdateLoopStore = defineStore('UpdateLoop', () => {
if (vrcxUpdaterStore.autoUpdateVRCX !== 'Off') { if (vrcxUpdaterStore.autoUpdateVRCX !== 'Off') {
vrcxUpdaterStore.checkForVRCXUpdate(); vrcxUpdaterStore.checkForVRCXUpdate();
} }
vrcxStore.tryAutoBackupVrcRegistry();
} }
if (--state.ipcTimeout <= 0) { if (--state.ipcTimeout <= 0) {
vrcxStore.ipcEnabled = false; vrcxStore.ipcEnabled = false;
+16 -8
View File
@@ -707,7 +707,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
lastBackupDate lastBackupDate
); );
} else { } else {
await autoBackupVrcRegistry(); await tryAutoBackupVrcRegistry();
} }
} }
@@ -715,7 +715,10 @@ export const useVrcxStore = defineStore('Vrcx', () => {
state.isRegistryBackupDialogVisible = true; state.isRegistryBackupDialogVisible = true;
} }
async function autoBackupVrcRegistry() { async function tryAutoBackupVrcRegistry() {
if (!advancedSettingsStore.vrcRegistryAutoBackup) {
return;
}
const date = new Date(); const date = new Date();
const lastBackupDate = await configRepository.getString( const lastBackupDate = await configRepository.getString(
'VRCX_VRChatRegistryLastBackupDate' 'VRCX_VRChatRegistryLastBackupDate'
@@ -724,7 +727,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
const lastBackup = new Date(lastBackupDate); const lastBackup = new Date(lastBackupDate);
const diff = date.getTime() - lastBackup.getTime(); const diff = date.getTime() - lastBackup.getTime();
const diffDays = Math.floor(diff / (1000 * 60 * 60 * 24)); const diffDays = Math.floor(diff / (1000 * 60 * 60 * 24));
if (diffDays < 7) { if (diffDays < 3) {
return; return;
} }
} }
@@ -735,12 +738,16 @@ export const useVrcxStore = defineStore('Vrcx', () => {
backupsJson = JSON.stringify([]); backupsJson = JSON.stringify([]);
} }
const backups = JSON.parse(backupsJson); const backups = JSON.parse(backupsJson);
backups.forEach((backup) => { for (let i = backups.length - 1; i >= 0; i--) {
if (backup.name === 'Auto Backup') { const backupDate = new Date(backups[i].date);
// remove old auto backup // remove backups older than 2 weeks
removeFromArray(backups, backup); if (
backups[i].name === 'Auto Backup' &&
backupDate.getTime() < date.getTime() - 1209600000 // 2 weeks in milliseconds
) {
backups.splice(i, 1);
}
} }
});
await configRepository.setString( await configRepository.setString(
'VRCX_VRChatRegistryBackups', 'VRCX_VRChatRegistryBackups',
JSON.stringify(backups) JSON.stringify(backups)
@@ -766,6 +773,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
eventVrcxMessage, eventVrcxMessage,
showRegistryBackupDialog, showRegistryBackupDialog,
checkAutoBackupRestoreVrcRegistry, checkAutoBackupRestoreVrcRegistry,
tryAutoBackupVrcRegistry,
processScreenshot, processScreenshot,
ipcEvent, ipcEvent,
dragEnterCef, dragEnterCef,