chore: fix errenous windows paths from previous migration
This commit is contained in:
@@ -1369,6 +1369,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
||||
singletonManager: this.singletonManager,
|
||||
featuresService: this.featuresService,
|
||||
environment: this.environment,
|
||||
platform: this.platform,
|
||||
identifier: this.identifier,
|
||||
internalEventBus: this.internalEventBus,
|
||||
legacySessionStorageMapper: this.legacySessionStorageMapper,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BackupServiceInterface } from '@standardnotes/files'
|
||||
import { Environment } from '@standardnotes/models'
|
||||
import { Environment, Platform } from '@standardnotes/models'
|
||||
import { DeviceInterface, InternalEventBusInterface, EncryptionService } from '@standardnotes/services'
|
||||
import { SNSessionManager } from '../Services/Session/SessionManager'
|
||||
import { ApplicationIdentifier } from '@standardnotes/common'
|
||||
@@ -18,6 +18,7 @@ export type MigrationServices = {
|
||||
singletonManager: SNSingletonManager
|
||||
featuresService: SNFeaturesService
|
||||
environment: Environment
|
||||
platform: Platform
|
||||
identifier: ApplicationIdentifier
|
||||
legacySessionStorageMapper: MapperInterface<LegacySession, Record<string, unknown>>
|
||||
internalEventBus: InternalEventBusInterface
|
||||
|
||||
@@ -30,9 +30,11 @@ export class Migration2_167_6 extends Migration {
|
||||
|
||||
if (fileBackupsEnabled) {
|
||||
const legacyLocation = await device.getLegacyFilesBackupsLocation()
|
||||
const newLocation = `${legacyLocation}/${this.services.backups.prependWorkspacePathForPath(
|
||||
FileBackupsDirectoryName,
|
||||
)}`
|
||||
const newLocation = await device.joinPaths(
|
||||
legacyLocation as string,
|
||||
await this.services.backups.prependWorkspacePathForPath(FileBackupsDirectoryName),
|
||||
)
|
||||
|
||||
await device.migrateLegacyFileBackupsToNewStructure(newLocation)
|
||||
this.services.storageService.setValue(StorageKey.FileBackupsLocation, newLocation)
|
||||
}
|
||||
@@ -41,9 +43,10 @@ export class Migration2_167_6 extends Migration {
|
||||
if (wasLegacyDisabled) {
|
||||
this.services.storageService.setValue(StorageKey.TextBackupsEnabled, false)
|
||||
} else {
|
||||
const newTextBackupsLocation = `${await device.getLegacyTextBackupsLocation()}/${this.services.backups.prependWorkspacePathForPath(
|
||||
TextBackupsDirectoryName,
|
||||
)}`
|
||||
const newTextBackupsLocation = await device.joinPaths(
|
||||
(await device.getLegacyTextBackupsLocation()) as string,
|
||||
await this.services.backups.prependWorkspacePathForPath(TextBackupsDirectoryName),
|
||||
)
|
||||
this.services.storageService.setValue(StorageKey.TextBackupsLocation, newTextBackupsLocation)
|
||||
this.services.storageService.setValue(StorageKey.TextBackupsEnabled, true)
|
||||
}
|
||||
|
||||
54
packages/snjs/lib/Migrations/Versions/2_168_6.ts
Normal file
54
packages/snjs/lib/Migrations/Versions/2_168_6.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { Platform } from '@standardnotes/models'
|
||||
import { ApplicationStage, StorageKey, isDesktopDevice } from '@standardnotes/services'
|
||||
import { Migration } from '@Lib/Migrations/Migration'
|
||||
|
||||
export class Migration2_168_6 extends Migration {
|
||||
static override version(): string {
|
||||
return '2.168.6'
|
||||
}
|
||||
|
||||
protected registerStageHandlers(): void {
|
||||
this.registerStageHandler(ApplicationStage.Launched_10, async () => {
|
||||
await this.migrateErroneousWindowsPathFromPreviousMigration()
|
||||
this.markDone()
|
||||
})
|
||||
}
|
||||
|
||||
private async migrateErroneousWindowsPathFromPreviousMigration(): Promise<void> {
|
||||
const device = this.services.deviceInterface
|
||||
if (!isDesktopDevice(device) || !this.services.backups) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.services.platform !== Platform.WindowsDesktop) {
|
||||
return
|
||||
}
|
||||
|
||||
const textBackupsLocation = this.services.backups.getTextBackupsLocation()
|
||||
if (textBackupsLocation) {
|
||||
const parts = textBackupsLocation.split('/')
|
||||
if (parts.length > 1) {
|
||||
const newLocation = await device.joinPaths(...parts)
|
||||
this.services.storageService.setValue(StorageKey.TextBackupsLocation, newLocation)
|
||||
}
|
||||
}
|
||||
|
||||
const fileBackupsLocation = this.services.backups.getFilesBackupsLocation()
|
||||
if (fileBackupsLocation) {
|
||||
const parts = fileBackupsLocation.split('/')
|
||||
if (parts.length > 1) {
|
||||
const newLocation = await device.joinPaths(...parts)
|
||||
this.services.storageService.setValue(StorageKey.FileBackupsLocation, newLocation)
|
||||
}
|
||||
}
|
||||
|
||||
const plaintextBackupsLocation = this.services.backups.getPlaintextBackupsLocation()
|
||||
if (plaintextBackupsLocation) {
|
||||
const parts = plaintextBackupsLocation.split('/')
|
||||
if (parts.length > 1) {
|
||||
const newLocation = await device.joinPaths(...parts)
|
||||
this.services.storageService.setValue(StorageKey.PlaintextBackupsLocation, newLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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'
|
||||
import { Migration2_168_6 } from './2_168_6'
|
||||
|
||||
export const MigrationClasses = [
|
||||
Migration2_0_15,
|
||||
@@ -12,6 +13,15 @@ export const MigrationClasses = [
|
||||
Migration2_36_0,
|
||||
Migration2_42_0,
|
||||
Migration2_167_6,
|
||||
Migration2_168_6,
|
||||
]
|
||||
|
||||
export { 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,
|
||||
Migration2_167_6,
|
||||
Migration2_168_6,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user