Removed forced cache saving
This commit is contained in:
		
							parent
							
								
									d85a132e50
								
							
						
					
					
						commit
						88923910aa
					
				| 
						 | 
				
			
			@ -285,7 +285,7 @@ export default class LocatorPlugin extends Plugin {
 | 
			
		|||
 | 
			
		||||
      // Disable settings.useCache while writing the cache, in case it freezes
 | 
			
		||||
      const cacheEnabled = this.settings.useCache
 | 
			
		||||
      if (cacheEnabled && !this.settings.DANGER_forceSaveCache) {
 | 
			
		||||
      if (cacheEnabled) {
 | 
			
		||||
        this.settings.useCache = false
 | 
			
		||||
        await saveSettings(this)
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -127,7 +127,6 @@ export function getDefaultSettings(app: App): LocatorSettings {
 | 
			
		|||
    verboseLogging: false,
 | 
			
		||||
 | 
			
		||||
    DANGER_httpHost: null,
 | 
			
		||||
    DANGER_forceSaveCache: false,
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
import { Setting } from 'obsidian'
 | 
			
		||||
import type LocatorPlugin from 'src/main'
 | 
			
		||||
import type { LocatorSettings } from './utils'
 | 
			
		||||
import { htmlDescription, isCacheEnabled, needsARestart, saveSettings } from './utils'
 | 
			
		||||
import { htmlDescription, isCacheEnabled, needsARestart } from './utils'
 | 
			
		||||
 | 
			
		||||
export function injectSettingsDanger(
 | 
			
		||||
  plugin: LocatorPlugin,
 | 
			
		||||
| 
						 | 
				
			
			@ -12,21 +12,6 @@ export function injectSettingsDanger(
 | 
			
		|||
 | 
			
		||||
  new Setting(containerEl).setName('Danger Zone').setHeading()
 | 
			
		||||
 | 
			
		||||
  // Force save cache
 | 
			
		||||
  new Setting(containerEl)
 | 
			
		||||
    .setName('Force save the cache')
 | 
			
		||||
    .setDesc(
 | 
			
		||||
      htmlDescription(`Locator has a security feature that automatically disables cache writing if it cannot fully perform the operation.<br>
 | 
			
		||||
      Use this option to force the cache to be saved, even if it causes a crash.<br>
 | 
			
		||||
      ⚠️ <span style="color: var(--text-accent)">Enabling this setting could lead to crash loops</span>`)
 | 
			
		||||
    )
 | 
			
		||||
    .addToggle(toggle =>
 | 
			
		||||
      toggle.setValue(settings.DANGER_forceSaveCache).onChange(async v => {
 | 
			
		||||
        settings.DANGER_forceSaveCache = v
 | 
			
		||||
        await saveSettings(plugin)
 | 
			
		||||
      })
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
  // Clear cache data
 | 
			
		||||
  if (isCacheEnabled()) {
 | 
			
		||||
    new Setting(containerEl)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,5 +82,4 @@ export interface LocatorSettings extends WeightingSettings {
 | 
			
		|||
  httpApiNotice: boolean
 | 
			
		||||
 | 
			
		||||
  DANGER_httpHost: string | null
 | 
			
		||||
  DANGER_forceSaveCache: boolean
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user