Refactor manipulation of nextcloud sync file

This commit is contained in:
Manuel Thalmann 2023-07-03 00:47:21 +02:00
parent 0a7851fabe
commit d85cea9cb2

View file

@ -244,13 +244,24 @@ class Context {
$configName += "WithPlaceholders"; $configName += "WithPlaceholders";
} }
Add-Content $($this.GetNextcloudConfigFile()) ` $accountSectionEntered = $false;
-Value (
Get-Content $($this.GetNextcloudConfigFile()) | `
ForEach-Object {
if ($_ -eq "[Accounts]") {
$accountSectionEntered = $true;
}
if ($_ -eq "" -and $accountSectionEntered) {
[string]::Join( [string]::Join(
"`n", "`n",
@( @(
"0\$configName\$folderID\localPath=$localPath", "0\$configName\$folderID\localPath=$localPath",
"0\$configName\$folderID\targetPath=$targetPath"))); "0\$configName\$folderID\targetPath=$targetPath"));
}
$_;
} | Set-Content $this.GetNextcloudConfigFile();
Start-Process $nextcloudPath; Start-Process $nextcloudPath;
} }