feat: Automatic plaintext backup option in Preferences > Backups will backup your notes and tags into plaintext, unencrypted folders on your computer. In addition, automatic encrypted text backups preference management has moved from the top-level menu in the desktop app to Preferences > Backups. (#2322)

This commit is contained in:
Mo
2023-05-02 11:05:10 -05:00
committed by GitHub
parent 3df23cdb5c
commit 7e3db49322
76 changed files with 1526 additions and 1013 deletions

View File

@@ -0,0 +1,51 @@
import {
ApplicationStage,
FileBackupsDirectoryName,
StorageKey,
TextBackupsDirectoryName,
isDesktopDevice,
} from '@standardnotes/services'
import { Migration } from '@Lib/Migrations/Migration'
export class Migration2_167_6 extends Migration {
static override version(): string {
return '2.167.6'
}
protected registerStageHandlers(): void {
this.registerStageHandler(ApplicationStage.Launched_10, async () => {
await this.migrateStorageKeysForDesktopBackups()
this.markDone()
})
}
private async migrateStorageKeysForDesktopBackups(): Promise<void> {
const device = this.services.deviceInterface
if (!isDesktopDevice(device) || !this.services.backups) {
return
}
const fileBackupsEnabled = await device.isLegacyFilesBackupsEnabled()
this.services.storageService.setValue(StorageKey.FileBackupsEnabled, fileBackupsEnabled)
if (fileBackupsEnabled) {
const legacyLocation = await device.getLegacyFilesBackupsLocation()
const newLocation = `${legacyLocation}/${this.services.backups.prependWorkspacePathForPath(
FileBackupsDirectoryName,
)}`
await device.migrateLegacyFileBackupsToNewStructure(newLocation)
this.services.storageService.setValue(StorageKey.FileBackupsLocation, newLocation)
}
const wasLegacyDisabled = await device.wasLegacyTextBackupsExplicitlyDisabled()
if (wasLegacyDisabled) {
this.services.storageService.setValue(StorageKey.TextBackupsEnabled, false)
} else {
const newTextBackupsLocation = `${await device.getLegacyTextBackupsLocation()}/${this.services.backups.prependWorkspacePathForPath(
TextBackupsDirectoryName,
)}`
this.services.storageService.setValue(StorageKey.TextBackupsLocation, newTextBackupsLocation)
this.services.storageService.setValue(StorageKey.TextBackupsEnabled, true)
}
}
}