mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-30 00:09:54 +00: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 {
|
private emitChange (): void {
|
||||||
this.changed.next()
|
|
||||||
this.vault.setStore(this.store.vault)
|
this.vault.setStore(this.store.vault)
|
||||||
|
this.changed.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
private migrate (config) {
|
private migrate (config) {
|
||||||
|
@ -96,7 +96,10 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
|||||||
li(ngbNavItem)
|
li(ngbNavItem)
|
||||||
a(ngbNavLink, translate) Advanced
|
a(ngbNavLink, translate) Advanced
|
||||||
ng-template(ngbNavContent)
|
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
|
.header
|
||||||
.title(translate) Sync hotkeys
|
.title(translate) Sync hotkeys
|
||||||
toggle(
|
toggle(
|
||||||
@ -104,7 +107,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
|||||||
(ngModelChange)='config.save()',
|
(ngModelChange)='config.save()',
|
||||||
)
|
)
|
||||||
|
|
||||||
.form-line
|
.form-line(*ngIf='!config.store.encrypted')
|
||||||
.header
|
.header
|
||||||
.title(translate) Sync window settings
|
.title(translate) Sync window settings
|
||||||
toggle(
|
toggle(
|
||||||
@ -112,7 +115,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
|||||||
(ngModelChange)='config.save()',
|
(ngModelChange)='config.save()',
|
||||||
)
|
)
|
||||||
|
|
||||||
.form-line
|
.form-line(*ngIf='!config.store.encrypted')
|
||||||
.header
|
.header
|
||||||
.title(translate) Sync Vault
|
.title(translate) Sync Vault
|
||||||
toggle(
|
toggle(
|
||||||
|
@ -86,7 +86,7 @@ export class ConfigSyncService {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
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
|
const remoteData = yaml.load((await this.getConfig(this.config.store.configSync.configID)).content) as any
|
||||||
for (const part of OPTIONAL_CONFIG_PARTS) {
|
for (const part of OPTIONAL_CONFIG_PARTS) {
|
||||||
if (!this.config.store.configSync.parts[part]) {
|
if (!this.config.store.configSync.parts[part]) {
|
||||||
@ -113,16 +113,19 @@ export class ConfigSyncService {
|
|||||||
try {
|
try {
|
||||||
const config = await this.getConfig(this.config.store.configSync.configID)
|
const config = await this.getConfig(this.config.store.configSync.configID)
|
||||||
const data = yaml.load(config.content) as any
|
const data = yaml.load(config.content) as any
|
||||||
|
|
||||||
const localData = yaml.load(this.config.readRaw()) as any
|
const localData = yaml.load(this.config.readRaw()) as any
|
||||||
data.configSync = localData.configSync
|
data.configSync = localData.configSync
|
||||||
|
|
||||||
|
if (!data.encrypted) {
|
||||||
for (const part of OPTIONAL_CONFIG_PARTS) {
|
for (const part of OPTIONAL_CONFIG_PARTS) {
|
||||||
if (!this.config.store.configSync.parts[part]) {
|
if (!this.config.store.configSync.parts[part]) {
|
||||||
data[part] = localData[part]
|
data[part] = localData[part]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.writeConfigDataFromSync(data)
|
await this.writeConfigDataFromSync(data)
|
||||||
this.logger.debug('Config downloaded')
|
this.logger.debug('Config downloaded')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('Download failed:', error)
|
this.logger.error('Download failed:', error)
|
||||||
@ -130,14 +133,16 @@ export class ConfigSyncService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readConfigDataForSync (): any {
|
private async readConfigDataForSync (): Promise<any> {
|
||||||
const data = yaml.load(this.config.readRaw()) as any
|
const data = yaml.load(await this.platform.loadConfig()) as any
|
||||||
delete data.configSync
|
delete data.configSync
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
private writeConfigDataFromSync (data: any) {
|
private async writeConfigDataFromSync (data: any) {
|
||||||
this.config.writeRaw(yaml.dump(data))
|
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 = {}) {
|
private async request (method: 'GET'|'POST'|'PATCH', url: string, params = {}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user