mirror of
https://github.com/Eugeny/tabby.git
synced 2025-03-01 15:06:27 +08:00
support syncing fully encrypted config - fixes #5400
This commit is contained in:
parent
a6a9c149dc
commit
21e5d68994
@ -270,8 +270,8 @@ export class ConfigService {
|
||||
}
|
||||
|
||||
private emitChange (): void {
|
||||
this.changed.next()
|
||||
this.vault.setStore(this.store.vault)
|
||||
this.changed.next()
|
||||
}
|
||||
|
||||
private migrate (config) {
|
||||
|
@ -96,7 +96,10 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
||||
li(ngbNavItem)
|
||||
a(ngbNavLink, translate) Advanced
|
||||
ng-template(ngbNavContent)
|
||||
.form-line
|
||||
.alert.alert-info(*ngIf='config.store.encrypted')
|
||||
div(translate) Partial config sync is not possible when the config is encrypted via Vault.
|
||||
|
||||
.form-line(*ngIf='!config.store.encrypted')
|
||||
.header
|
||||
.title(translate) Sync hotkeys
|
||||
toggle(
|
||||
@ -104,7 +107,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
||||
(ngModelChange)='config.save()',
|
||||
)
|
||||
|
||||
.form-line
|
||||
.form-line(*ngIf='!config.store.encrypted')
|
||||
.header
|
||||
.title(translate) Sync window settings
|
||||
toggle(
|
||||
@ -112,7 +115,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
||||
(ngModelChange)='config.save()',
|
||||
)
|
||||
|
||||
.form-line
|
||||
.form-line(*ngIf='!config.store.encrypted')
|
||||
.header
|
||||
.title(translate) Sync Vault
|
||||
toggle(
|
||||
|
@ -86,7 +86,7 @@ export class ConfigSyncService {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = this.readConfigDataForSync()
|
||||
const data = await this.readConfigDataForSync()
|
||||
const remoteData = yaml.load((await this.getConfig(this.config.store.configSync.configID)).content) as any
|
||||
for (const part of OPTIONAL_CONFIG_PARTS) {
|
||||
if (!this.config.store.configSync.parts[part]) {
|
||||
@ -113,16 +113,19 @@ export class ConfigSyncService {
|
||||
try {
|
||||
const config = await this.getConfig(this.config.store.configSync.configID)
|
||||
const data = yaml.load(config.content) as any
|
||||
|
||||
const localData = yaml.load(this.config.readRaw()) as any
|
||||
data.configSync = localData.configSync
|
||||
|
||||
for (const part of OPTIONAL_CONFIG_PARTS) {
|
||||
if (!this.config.store.configSync.parts[part]) {
|
||||
data[part] = localData[part]
|
||||
if (!data.encrypted) {
|
||||
for (const part of OPTIONAL_CONFIG_PARTS) {
|
||||
if (!this.config.store.configSync.parts[part]) {
|
||||
data[part] = localData[part]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.writeConfigDataFromSync(data)
|
||||
await this.writeConfigDataFromSync(data)
|
||||
this.logger.debug('Config downloaded')
|
||||
} catch (error) {
|
||||
this.logger.error('Download failed:', error)
|
||||
@ -130,14 +133,16 @@ export class ConfigSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
private readConfigDataForSync (): any {
|
||||
const data = yaml.load(this.config.readRaw()) as any
|
||||
private async readConfigDataForSync (): Promise<any> {
|
||||
const data = yaml.load(await this.platform.loadConfig()) as any
|
||||
delete data.configSync
|
||||
return data
|
||||
}
|
||||
|
||||
private writeConfigDataFromSync (data: any) {
|
||||
this.config.writeRaw(yaml.dump(data))
|
||||
private async writeConfigDataFromSync (data: any) {
|
||||
await this.platform.saveConfig(yaml.dump(data))
|
||||
await this.config.load()
|
||||
await this.config.save()
|
||||
}
|
||||
|
||||
private async request (method: 'GET'|'POST'|'PATCH', url: string, params = {}) {
|
||||
|
Loading…
Reference in New Issue
Block a user