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:
@@ -1,6 +1,6 @@
|
||||
import { BackupServiceInterface } from '@standardnotes/files'
|
||||
import { Environment } from '@standardnotes/models'
|
||||
import { DeviceInterface, InternalEventBusInterface, EncryptionService } from '@standardnotes/services'
|
||||
|
||||
import { SNSessionManager } from '../Services/Session/SessionManager'
|
||||
import { ApplicationIdentifier } from '@standardnotes/common'
|
||||
import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
@@ -13,6 +13,7 @@ export type MigrationServices = {
|
||||
storageService: DiskStorageService
|
||||
challengeService: ChallengeService
|
||||
sessionManager: SNSessionManager
|
||||
backups?: BackupServiceInterface
|
||||
itemManager: ItemManager
|
||||
singletonManager: SNSingletonManager
|
||||
featuresService: SNFeaturesService
|
||||
|
||||
51
packages/snjs/lib/Migrations/Versions/2_167_6.ts
Normal file
51
packages/snjs/lib/Migrations/Versions/2_167_6.ts
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
5
packages/snjs/lib/Migrations/Versions/README.md
Normal file
5
packages/snjs/lib/Migrations/Versions/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
## To create a migration:
|
||||
|
||||
1. Create a new file inside versions specifiying the would-be version of SNJS that would result when publishing your migration. For example, if the current SNJS version is 1.0.0 in package.json, your migration version should be 1.0.1 to target users below this version.
|
||||
|
||||
2. **Important** Export your migration inside the index.ts file.
|
||||
@@ -3,7 +3,15 @@ import { Migration2_7_0 } from './2_7_0'
|
||||
import { Migration2_20_0 } from './2_20_0'
|
||||
import { Migration2_36_0 } from './2_36_0'
|
||||
import { Migration2_42_0 } from './2_42_0'
|
||||
import { Migration2_167_6 } from './2_167_6'
|
||||
|
||||
export const MigrationClasses = [Migration2_0_15, Migration2_7_0, Migration2_20_0, Migration2_36_0, Migration2_42_0]
|
||||
export const MigrationClasses = [
|
||||
Migration2_0_15,
|
||||
Migration2_7_0,
|
||||
Migration2_20_0,
|
||||
Migration2_36_0,
|
||||
Migration2_42_0,
|
||||
Migration2_167_6,
|
||||
]
|
||||
|
||||
export { Migration2_0_15, Migration2_7_0, Migration2_20_0, Migration2_36_0, Migration2_42_0 }
|
||||
export { Migration2_0_15, Migration2_7_0, Migration2_20_0, Migration2_36_0, Migration2_42_0, Migration2_167_6 }
|
||||
|
||||
Reference in New Issue
Block a user