fix: desktop backups directory change (#1178)
* fix: only move backup related files when changing file backups location * fix: remove presently recursive error handling for third party component installation
This commit is contained in:
@@ -2,9 +2,11 @@ import { FileBackupsDevice, FileBackupsMapping } from '@web/Application/Device/D
|
||||
import { AppState } from 'app/application'
|
||||
import { shell } from 'electron'
|
||||
import { StoreKeys } from '../Store'
|
||||
import path from 'path'
|
||||
import {
|
||||
deleteFile,
|
||||
ensureDirectoryExists,
|
||||
moveDirContents,
|
||||
moveFiles,
|
||||
openDirectoryPicker,
|
||||
readJSONFile,
|
||||
writeFile,
|
||||
@@ -61,12 +63,37 @@ export class FilesBackupManager implements FileBackupsDevice {
|
||||
const oldPath = await this.getFilesBackupsLocation()
|
||||
|
||||
if (oldPath) {
|
||||
await moveDirContents(oldPath, newPath)
|
||||
await this.transferFilesBackupsToNewLocation(oldPath, newPath)
|
||||
} else {
|
||||
this.appState.store.set(StoreKeys.FileBackupsLocation, newPath)
|
||||
}
|
||||
|
||||
return newPath
|
||||
}
|
||||
|
||||
private async transferFilesBackupsToNewLocation(oldPath: string, newPath: string): Promise<void> {
|
||||
const mapping = await this.getMappingFileFromDisk()
|
||||
if (!mapping) {
|
||||
return
|
||||
}
|
||||
|
||||
const entries = Object.values(mapping.files)
|
||||
const itemFolders = entries.map((entry) => path.join(oldPath, entry.relativePath))
|
||||
await moveFiles(itemFolders, newPath)
|
||||
|
||||
for (const entry of entries) {
|
||||
entry.absolutePath = path.join(newPath, entry.relativePath)
|
||||
}
|
||||
|
||||
const oldMappingFileLocation = this.getMappingFileLocation()
|
||||
|
||||
this.appState.store.set(StoreKeys.FileBackupsLocation, newPath)
|
||||
|
||||
return newPath
|
||||
const result = await this.saveFilesBackupsMappingFile(mapping)
|
||||
|
||||
if (result === 'success') {
|
||||
await deleteFile(oldMappingFileLocation)
|
||||
}
|
||||
}
|
||||
|
||||
public getFilesBackupsLocation(): Promise<string> {
|
||||
|
||||
@@ -288,12 +288,13 @@ async function installComponent(
|
||||
const sendInstalledMessage = (component: Component, error?: { message: string; tag: string }) => {
|
||||
if (error) {
|
||||
logError(`Error when installing component ${name}: ` + error.message)
|
||||
} else {
|
||||
logMessage(`Installed component ${name} (${version})`)
|
||||
return
|
||||
}
|
||||
|
||||
logMessage(`Installed component ${name} (${version})`)
|
||||
|
||||
webContents.send(MessageToWebApp.InstallComponentComplete, {
|
||||
component,
|
||||
error,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user