Restore saved options from disk Abandons any changes not written to disk.
(self)
| 413 | self.overrides.clear() |
| 414 | |
| 415 | def restore(self): |
| 416 | """Restore saved options from disk |
| 417 | |
| 418 | Abandons any changes not written to disk. |
| 419 | """ |
| 420 | with self._flush_lock: |
| 421 | self.__cancel_flush_timer() |
| 422 | self._dirty = False |
| 423 | # Reading configuration merges with existing data, |
| 424 | # so clear it first. |
| 425 | for section in self.config.sections(): |
| 426 | self.config.remove_section(section) |
| 427 | try: |
| 428 | self.config.read(bleachbit.options_file, encoding='utf-8-sig') |
| 429 | except: |
| 430 | logger.exception("Error reading application's configuration") |
| 431 | if not self.config.has_section("bleachbit"): |
| 432 | self.config.add_section("bleachbit") |
| 433 | if not self.config.has_section("hashpath"): |
| 434 | self.config.add_section("hashpath") |
| 435 | if not self.config.has_section("list/shred_drives"): |
| 436 | from bleachbit.FileUtilities import guess_overwrite_paths |
| 437 | try: |
| 438 | self.set_list('shred_drives', guess_overwrite_paths()) |
| 439 | except: |
| 440 | logger.exception( |
| 441 | _("Error when setting the default drives to shred.")) |
| 442 | # BleachBit upgrade or first start ever |
| 443 | if not self.config.has_option('bleachbit', 'version') or \ |
| 444 | self.get('version') != bleachbit.APP_VERSION: |
| 445 | if self.config.has_option('bleachbit', 'version'): |
| 446 | self.old_version = self.get('version') |
| 447 | self.set('first_start', True) |
| 448 | |
| 449 | # set version |
| 450 | self.set("version", bleachbit.APP_VERSION) |
| 451 | |
| 452 | def set(self, key, value, section='bleachbit'): |
| 453 | """Set a general option""" |