chore: fix errenous windows paths from previous migration
This commit is contained in:
@@ -62,6 +62,10 @@ export class FilesBackupManager implements FileBackupsDevice {
|
|||||||
return uuid
|
return uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async joinPaths(...paths: string[]): Promise<string> {
|
||||||
|
return path.join(...paths)
|
||||||
|
}
|
||||||
|
|
||||||
public async migrateLegacyFileBackupsToNewStructure(newLocation: string): Promise<void> {
|
public async migrateLegacyFileBackupsToNewStructure(newLocation: string): Promise<void> {
|
||||||
const legacyLocation = await this.getLegacyFilesBackupsLocation()
|
const legacyLocation = await this.getLegacyFilesBackupsLocation()
|
||||||
if (!legacyLocation) {
|
if (!legacyLocation) {
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ export class RemoteBridge implements CrossProcessBridge {
|
|||||||
migrateLegacyFileBackupsToNewStructure: this.migrateLegacyFileBackupsToNewStructure.bind(this),
|
migrateLegacyFileBackupsToNewStructure: this.migrateLegacyFileBackupsToNewStructure.bind(this),
|
||||||
getUserDocumentsDirectory: this.getUserDocumentsDirectory.bind(this),
|
getUserDocumentsDirectory: this.getUserDocumentsDirectory.bind(this),
|
||||||
monitorPlaintextBackupsLocationForChanges: this.monitorPlaintextBackupsLocationForChanges.bind(this),
|
monitorPlaintextBackupsLocationForChanges: this.monitorPlaintextBackupsLocationForChanges.bind(this),
|
||||||
|
joinPaths: this.joinPaths.bind(this),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,6 +236,10 @@ export class RemoteBridge implements CrossProcessBridge {
|
|||||||
return this.fileBackups.monitorPlaintextBackupsLocationForChanges(backupsDirectory)
|
return this.fileBackups.monitorPlaintextBackupsLocationForChanges(backupsDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
joinPaths(...paths: string[]): Promise<string> {
|
||||||
|
return this.fileBackups.joinPaths(...paths)
|
||||||
|
}
|
||||||
|
|
||||||
askForMediaAccess(type: 'camera' | 'microphone'): Promise<boolean> {
|
askForMediaAccess(type: 'camera' | 'microphone'): Promise<boolean> {
|
||||||
return this.media.askForMediaAccess(type)
|
return this.media.askForMediaAccess(type)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ export class DesktopDevice extends WebOrDesktopDevice implements DesktopDeviceIn
|
|||||||
return this.remoteBridge.monitorPlaintextBackupsLocationForChanges(backupsDirectory)
|
return this.remoteBridge.monitorPlaintextBackupsLocationForChanges(backupsDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
joinPaths(...paths: string[]): Promise<string> {
|
||||||
|
return this.remoteBridge.joinPaths(...paths)
|
||||||
|
}
|
||||||
|
|
||||||
async performHardReset(): Promise<void> {
|
async performHardReset(): Promise<void> {
|
||||||
console.error('performHardReset is not yet implemented')
|
console.error('performHardReset is not yet implemented')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ export interface FileBackupsDevice
|
|||||||
TextBackupsMethods {
|
TextBackupsMethods {
|
||||||
openLocation(path: string): Promise<void>
|
openLocation(path: string): Promise<void>
|
||||||
|
|
||||||
|
joinPaths(...paths: string[]): Promise<string>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The reason we combine presenting a directory picker and transfering old files to the new location
|
* The reason we combine presenting a directory picker and transfering old files to the new location
|
||||||
* in one function is so we don't have to expose a general `transferDirectories` function to the web app,
|
* in one function is so we don't have to expose a general `transferDirectories` function to the web app,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { SuperConverterServiceInterface } from './SuperConverterServiceInterface
|
|||||||
|
|
||||||
export interface BackupServiceInterface {
|
export interface BackupServiceInterface {
|
||||||
openAllDirectoriesContainingBackupFiles(): void
|
openAllDirectoriesContainingBackupFiles(): void
|
||||||
prependWorkspacePathForPath(path: string): string
|
prependWorkspacePathForPath(path: string): Promise<string>
|
||||||
importWatchedDirectoryChanges(changes: DesktopWatchedDirectoriesChanges): Promise<void>
|
importWatchedDirectoryChanges(changes: DesktopWatchedDirectoriesChanges): Promise<void>
|
||||||
setSuperConverter(converter: SuperConverterServiceInterface): void
|
setSuperConverter(converter: SuperConverterServiceInterface): void
|
||||||
|
|
||||||
|
|||||||
@@ -184,17 +184,17 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
return this.storage.getValue(StorageKey.TextBackupsEnabled, undefined, true)
|
return this.storage.getValue(StorageKey.TextBackupsEnabled, undefined, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
prependWorkspacePathForPath(path: string): string {
|
async prependWorkspacePathForPath(path: string): Promise<string> {
|
||||||
const workspacePath = this.session.getWorkspaceDisplayIdentifier()
|
const workspacePath = this.session.getWorkspaceDisplayIdentifier()
|
||||||
|
|
||||||
return `${workspacePath}/${path}`
|
return this.device.joinPaths(workspacePath, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
async enableTextBackups(): Promise<void> {
|
async enableTextBackups(): Promise<void> {
|
||||||
let location = this.getTextBackupsLocation()
|
let location = this.getTextBackupsLocation()
|
||||||
if (!location) {
|
if (!location) {
|
||||||
location = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
location = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
||||||
this.prependWorkspacePathForPath(TextBackupsDirectoryName),
|
await this.prependWorkspacePathForPath(TextBackupsDirectoryName),
|
||||||
)
|
)
|
||||||
if (!location) {
|
if (!location) {
|
||||||
return
|
return
|
||||||
@@ -223,7 +223,7 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
async changeTextBackupsLocation(): Promise<string | undefined> {
|
async changeTextBackupsLocation(): Promise<string | undefined> {
|
||||||
const oldLocation = this.getTextBackupsLocation()
|
const oldLocation = this.getTextBackupsLocation()
|
||||||
const newLocation = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
const newLocation = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
||||||
this.prependWorkspacePathForPath(TextBackupsDirectoryName),
|
await this.prependWorkspacePathForPath(TextBackupsDirectoryName),
|
||||||
oldLocation,
|
oldLocation,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
let location = this.getPlaintextBackupsLocation()
|
let location = this.getPlaintextBackupsLocation()
|
||||||
if (!location) {
|
if (!location) {
|
||||||
location = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
location = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
||||||
this.prependWorkspacePathForPath(PlaintextBackupsDirectoryName),
|
await this.prependWorkspacePathForPath(PlaintextBackupsDirectoryName),
|
||||||
)
|
)
|
||||||
if (!location) {
|
if (!location) {
|
||||||
return
|
return
|
||||||
@@ -285,7 +285,7 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
async changePlaintextBackupsLocation(): Promise<string | undefined> {
|
async changePlaintextBackupsLocation(): Promise<string | undefined> {
|
||||||
const oldLocation = this.getPlaintextBackupsLocation()
|
const oldLocation = this.getPlaintextBackupsLocation()
|
||||||
const newLocation = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
const newLocation = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
||||||
this.prependWorkspacePathForPath(PlaintextBackupsDirectoryName),
|
await this.prependWorkspacePathForPath(PlaintextBackupsDirectoryName),
|
||||||
oldLocation,
|
oldLocation,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
let location = this.getFilesBackupsLocation()
|
let location = this.getFilesBackupsLocation()
|
||||||
if (!location) {
|
if (!location) {
|
||||||
location = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
location = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
||||||
this.prependWorkspacePathForPath(FileBackupsDirectoryName),
|
await this.prependWorkspacePathForPath(FileBackupsDirectoryName),
|
||||||
)
|
)
|
||||||
if (!location) {
|
if (!location) {
|
||||||
return
|
return
|
||||||
@@ -328,7 +328,7 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
public async changeFilesBackupsLocation(): Promise<string | undefined> {
|
public async changeFilesBackupsLocation(): Promise<string | undefined> {
|
||||||
const oldLocation = this.getFilesBackupsLocation()
|
const oldLocation = this.getFilesBackupsLocation()
|
||||||
const newLocation = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
const newLocation = await this.device.presentDirectoryPickerForLocationChangeAndTransferOld(
|
||||||
this.prependWorkspacePathForPath(FileBackupsDirectoryName),
|
await this.prependWorkspacePathForPath(FileBackupsDirectoryName),
|
||||||
oldLocation,
|
oldLocation,
|
||||||
)
|
)
|
||||||
if (!newLocation) {
|
if (!newLocation) {
|
||||||
|
|||||||
@@ -1369,6 +1369,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
|||||||
singletonManager: this.singletonManager,
|
singletonManager: this.singletonManager,
|
||||||
featuresService: this.featuresService,
|
featuresService: this.featuresService,
|
||||||
environment: this.environment,
|
environment: this.environment,
|
||||||
|
platform: this.platform,
|
||||||
identifier: this.identifier,
|
identifier: this.identifier,
|
||||||
internalEventBus: this.internalEventBus,
|
internalEventBus: this.internalEventBus,
|
||||||
legacySessionStorageMapper: this.legacySessionStorageMapper,
|
legacySessionStorageMapper: this.legacySessionStorageMapper,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { BackupServiceInterface } from '@standardnotes/files'
|
import { BackupServiceInterface } from '@standardnotes/files'
|
||||||
import { Environment } from '@standardnotes/models'
|
import { Environment, Platform } from '@standardnotes/models'
|
||||||
import { DeviceInterface, InternalEventBusInterface, EncryptionService } from '@standardnotes/services'
|
import { DeviceInterface, InternalEventBusInterface, EncryptionService } from '@standardnotes/services'
|
||||||
import { SNSessionManager } from '../Services/Session/SessionManager'
|
import { SNSessionManager } from '../Services/Session/SessionManager'
|
||||||
import { ApplicationIdentifier } from '@standardnotes/common'
|
import { ApplicationIdentifier } from '@standardnotes/common'
|
||||||
@@ -18,6 +18,7 @@ export type MigrationServices = {
|
|||||||
singletonManager: SNSingletonManager
|
singletonManager: SNSingletonManager
|
||||||
featuresService: SNFeaturesService
|
featuresService: SNFeaturesService
|
||||||
environment: Environment
|
environment: Environment
|
||||||
|
platform: Platform
|
||||||
identifier: ApplicationIdentifier
|
identifier: ApplicationIdentifier
|
||||||
legacySessionStorageMapper: MapperInterface<LegacySession, Record<string, unknown>>
|
legacySessionStorageMapper: MapperInterface<LegacySession, Record<string, unknown>>
|
||||||
internalEventBus: InternalEventBusInterface
|
internalEventBus: InternalEventBusInterface
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ export class Migration2_167_6 extends Migration {
|
|||||||
|
|
||||||
if (fileBackupsEnabled) {
|
if (fileBackupsEnabled) {
|
||||||
const legacyLocation = await device.getLegacyFilesBackupsLocation()
|
const legacyLocation = await device.getLegacyFilesBackupsLocation()
|
||||||
const newLocation = `${legacyLocation}/${this.services.backups.prependWorkspacePathForPath(
|
const newLocation = await device.joinPaths(
|
||||||
FileBackupsDirectoryName,
|
legacyLocation as string,
|
||||||
)}`
|
await this.services.backups.prependWorkspacePathForPath(FileBackupsDirectoryName),
|
||||||
|
)
|
||||||
|
|
||||||
await device.migrateLegacyFileBackupsToNewStructure(newLocation)
|
await device.migrateLegacyFileBackupsToNewStructure(newLocation)
|
||||||
this.services.storageService.setValue(StorageKey.FileBackupsLocation, newLocation)
|
this.services.storageService.setValue(StorageKey.FileBackupsLocation, newLocation)
|
||||||
}
|
}
|
||||||
@@ -41,9 +43,10 @@ export class Migration2_167_6 extends Migration {
|
|||||||
if (wasLegacyDisabled) {
|
if (wasLegacyDisabled) {
|
||||||
this.services.storageService.setValue(StorageKey.TextBackupsEnabled, false)
|
this.services.storageService.setValue(StorageKey.TextBackupsEnabled, false)
|
||||||
} else {
|
} else {
|
||||||
const newTextBackupsLocation = `${await device.getLegacyTextBackupsLocation()}/${this.services.backups.prependWorkspacePathForPath(
|
const newTextBackupsLocation = await device.joinPaths(
|
||||||
TextBackupsDirectoryName,
|
(await device.getLegacyTextBackupsLocation()) as string,
|
||||||
)}`
|
await this.services.backups.prependWorkspacePathForPath(TextBackupsDirectoryName),
|
||||||
|
)
|
||||||
this.services.storageService.setValue(StorageKey.TextBackupsLocation, newTextBackupsLocation)
|
this.services.storageService.setValue(StorageKey.TextBackupsLocation, newTextBackupsLocation)
|
||||||
this.services.storageService.setValue(StorageKey.TextBackupsEnabled, true)
|
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_36_0 } from './2_36_0'
|
||||||
import { Migration2_42_0 } from './2_42_0'
|
import { Migration2_42_0 } from './2_42_0'
|
||||||
import { Migration2_167_6 } from './2_167_6'
|
import { Migration2_167_6 } from './2_167_6'
|
||||||
|
import { Migration2_168_6 } from './2_168_6'
|
||||||
|
|
||||||
export const MigrationClasses = [
|
export const MigrationClasses = [
|
||||||
Migration2_0_15,
|
Migration2_0_15,
|
||||||
@@ -12,6 +13,15 @@ export const MigrationClasses = [
|
|||||||
Migration2_36_0,
|
Migration2_36_0,
|
||||||
Migration2_42_0,
|
Migration2_42_0,
|
||||||
Migration2_167_6,
|
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