mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
VRC reg auto back every 3days
This commit is contained in:
@@ -111,6 +111,7 @@ export const useUpdateLoopStore = defineStore('UpdateLoop', () => {
|
||||
if (vrcxUpdaterStore.autoUpdateVRCX !== 'Off') {
|
||||
vrcxUpdaterStore.checkForVRCXUpdate();
|
||||
}
|
||||
vrcxStore.tryAutoBackupVrcRegistry();
|
||||
}
|
||||
if (--state.ipcTimeout <= 0) {
|
||||
vrcxStore.ipcEnabled = false;
|
||||
|
||||
+16
-8
@@ -707,7 +707,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
lastBackupDate
|
||||
);
|
||||
} else {
|
||||
await autoBackupVrcRegistry();
|
||||
await tryAutoBackupVrcRegistry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,7 +715,10 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
state.isRegistryBackupDialogVisible = true;
|
||||
}
|
||||
|
||||
async function autoBackupVrcRegistry() {
|
||||
async function tryAutoBackupVrcRegistry() {
|
||||
if (!advancedSettingsStore.vrcRegistryAutoBackup) {
|
||||
return;
|
||||
}
|
||||
const date = new Date();
|
||||
const lastBackupDate = await configRepository.getString(
|
||||
'VRCX_VRChatRegistryLastBackupDate'
|
||||
@@ -724,7 +727,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
const lastBackup = new Date(lastBackupDate);
|
||||
const diff = date.getTime() - lastBackup.getTime();
|
||||
const diffDays = Math.floor(diff / (1000 * 60 * 60 * 24));
|
||||
if (diffDays < 7) {
|
||||
if (diffDays < 3) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -735,12 +738,16 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
backupsJson = JSON.stringify([]);
|
||||
}
|
||||
const backups = JSON.parse(backupsJson);
|
||||
backups.forEach((backup) => {
|
||||
if (backup.name === 'Auto Backup') {
|
||||
// remove old auto backup
|
||||
removeFromArray(backups, backup);
|
||||
for (let i = backups.length - 1; i >= 0; i--) {
|
||||
const backupDate = new Date(backups[i].date);
|
||||
// remove backups older than 2 weeks
|
||||
if (
|
||||
backups[i].name === 'Auto Backup' &&
|
||||
backupDate.getTime() < date.getTime() - 1209600000 // 2 weeks in milliseconds
|
||||
) {
|
||||
backups.splice(i, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
await configRepository.setString(
|
||||
'VRCX_VRChatRegistryBackups',
|
||||
JSON.stringify(backups)
|
||||
@@ -766,6 +773,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
eventVrcxMessage,
|
||||
showRegistryBackupDialog,
|
||||
checkAutoBackupRestoreVrcRegistry,
|
||||
tryAutoBackupVrcRegistry,
|
||||
processScreenshot,
|
||||
ipcEvent,
|
||||
dragEnterCef,
|
||||
|
||||
Reference in New Issue
Block a user