refactor(desktop): backup paths
This commit is contained in:
@@ -18,7 +18,7 @@ export interface BackupServiceInterface {
|
|||||||
getFilesBackupsLocation(): string | undefined
|
getFilesBackupsLocation(): string | undefined
|
||||||
openFilesBackupsLocation(): Promise<void>
|
openFilesBackupsLocation(): Promise<void>
|
||||||
openFileBackup(record: FileBackupRecord): Promise<void>
|
openFileBackup(record: FileBackupRecord): Promise<void>
|
||||||
getFileBackupAbsolutePath(record: FileBackupRecord): string
|
getFileBackupAbsolutePath(record: FileBackupRecord): Promise<string>
|
||||||
|
|
||||||
isTextBackupsEnabled(): boolean
|
isTextBackupsEnabled(): boolean
|
||||||
enableTextBackups(): Promise<void>
|
enableTextBackups(): Promise<void>
|
||||||
|
|||||||
@@ -147,9 +147,10 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
private async automaticallyEnableTextBackupsIfPreferenceNotSet(): Promise<void> {
|
private async automaticallyEnableTextBackupsIfPreferenceNotSet(): Promise<void> {
|
||||||
if (this.storage.getValue(StorageKey.TextBackupsEnabled) == undefined) {
|
if (this.storage.getValue(StorageKey.TextBackupsEnabled) == undefined) {
|
||||||
this.storage.setValue(StorageKey.TextBackupsEnabled, true)
|
this.storage.setValue(StorageKey.TextBackupsEnabled, true)
|
||||||
const location = `${await this.device.getUserDocumentsDirectory()}/${await this.prependWorkspacePathForPath(
|
const location = await this.device.joinPaths(
|
||||||
TextBackupsDirectoryName,
|
await this.device.getUserDocumentsDirectory(),
|
||||||
)}`
|
await this.prependWorkspacePathForPath(TextBackupsDirectoryName),
|
||||||
|
)
|
||||||
this.storage.setValue(StorageKey.TextBackupsLocation, location)
|
this.storage.setValue(StorageKey.TextBackupsLocation, location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,13 +379,16 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
return record
|
return record
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFileBackupAbsolutePath(record: FileBackupRecord): string {
|
public getFileBackupAbsolutePath(record: FileBackupRecord): Promise<string> {
|
||||||
const location = this.getFilesBackupsLocation()
|
const location = this.getFilesBackupsLocation()
|
||||||
return `${location}/${record.relativePath}`
|
if (!location) {
|
||||||
|
throw new ClientDisplayableError('No files backups location set')
|
||||||
|
}
|
||||||
|
return this.device.joinPaths(location, record.relativePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async openFileBackup(record: FileBackupRecord): Promise<void> {
|
public async openFileBackup(record: FileBackupRecord): Promise<void> {
|
||||||
const location = this.getFileBackupAbsolutePath(record)
|
const location = await this.getFileBackupAbsolutePath(record)
|
||||||
await this.device.openLocation(location)
|
await this.device.openLocation(location)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,7 +463,13 @@ export class FilesBackupService extends AbstractService implements BackupService
|
|||||||
return 'failed'
|
return 'failed'
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = `${this.getFilesBackupsLocation()}/${fileBackup.relativePath}/${fileBackup.binaryFileName}`
|
const fileBackupsLocation = await this.getFilesBackupsLocation()
|
||||||
|
|
||||||
|
if (!fileBackupsLocation) {
|
||||||
|
return 'failed'
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = await this.device.joinPaths(fileBackupsLocation, fileBackup.relativePath, fileBackup.binaryFileName)
|
||||||
const token = await this.device.getFileBackupReadToken(path)
|
const token = await this.device.getFileBackupReadToken(path)
|
||||||
|
|
||||||
let readMore = true
|
let readMore = true
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "3.161.0",
|
"version": "3.161.0",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"main": "dist/app.js",
|
"main": "dist/app.js",
|
||||||
"author": "Standard Notes.",
|
"author": "Standard Notes",
|
||||||
"private": true,
|
"private": true,
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|||||||
Reference in New Issue
Block a user