From 3f7fd36f845a0c80ae32620196b9eb5cc7615ced Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 15 Apr 2025 20:28:49 +0200 Subject: [PATCH] Fix files being linked as folders --- .vscode/launch.json | 16 ++++++++++++++++ instruction.go | 24 ++++++++++++------------ 2 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..c72851c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Ereshor Workspace", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}", + "cwd": "C:\\Users\\Administrator\\Seafile\\Games-Ereshor" + } + ] +} \ No newline at end of file diff --git a/instruction.go b/instruction.go index afe9ad8..fd122eb 100644 --- a/instruction.go +++ b/instruction.go @@ -337,21 +337,21 @@ func ExpandPattern(source, workdir, target string) (links []LinkInstruction, err } for _, file := range files { + if len(files) == 1 { + // Special case: if there is only one file + // This should only ever happen if our source is a path (and not a glob!) + // And our target is a path + // ...but it will also happen if the source IS a glob and it happens to match ONE file + // I think that should happen rarely enough to not be an issue... + links = append(links, LinkInstruction{ + Source: filepath.Join(static, file), + Target: target, + }) + continue + } if info, err := os.Stat(file); err == nil && info.IsDir() { // We don't care about matched directories // We want files within them - if len(files) == 1 { - // Special case: if there is only one file, and it's a directory - // This should only ever happen if our source is a path (and not a glob!) - // And our target is a path, a directory - // ...but it will also happen if the source IS a glob and it happens to match ONE directory - // I think that should happen rarely enough to not be an issue... - links = append(links, LinkInstruction{ - Source: filepath.Join(static, file), - Target: target, - }) - continue - } LogInfo("Skipping directory %s", file) continue }