Fix duplication of new paths

This commit is contained in:
2024-08-13 10:25:22 +02:00
parent 1d71fe5aca
commit 205d4029be
2 changed files with 10 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ import (
"net/url" "net/url"
"os" "os"
"path" "path"
"path/filepath"
"strings" "strings"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
@@ -96,8 +97,10 @@ func main() {
continue continue
} }
newEntry := Entry{ newEntry := Entry{
FolderURI: path.Clean(path.Join(folder, fileEntry.Name())), FolderURI: filepath.ToSlash(path.Clean(path.Join(folder, fileEntry.Name()))),
} }
// Lowercase disk letters... Because it's what vscode would have wanted
newEntry.FolderURI = strings.ToLower(newEntry.FolderURI[:1]) + newEntry.FolderURI[1:]
_, exists := cleanConfig[newEntry.FolderURI] _, exists := cleanConfig[newEntry.FolderURI]
if exists { if exists {
log.Printf("Folder %s already exists in config", newEntry.FolderURI) log.Printf("Folder %s already exists in config", newEntry.FolderURI)

View File

@@ -4,12 +4,12 @@ type Config struct {
Entries []Entry `json:"entries"` Entries []Entry `json:"entries"`
} }
type Entry struct { type Entry struct {
FolderURI string `json:"folderUri,omitempty"` FolderURI string `json:"folderUri,omitempty"`
Workspace Workspace `json:"workspace,omitempty"` Workspace *Workspace `json:"workspace,omitempty"`
FileURI string `json:"fileUri,omitempty"` FileURI string `json:"fileUri,omitempty"`
Label string `json:"label,omitempty"` Label string `json:"label,omitempty"`
} }
type Workspace struct { type Workspace struct {
ID string `json:"id"` ID string `json:"id,omitempty"`
ConfigPath string `json:"configPath"` ConfigPath string `json:"configPath,omitempty"`
} }