From 3b418bcc16f49cb09abf5f3366cb8c1d9dabeb97 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Sun, 3 Mar 2024 11:29:11 +0100 Subject: [PATCH] Networks share paths that starts with \\ no longer need to be manually escaped (#250) - **FIXED** Networks share paths that starts with \\ no longer need to be manually escaped (fixes https://github.com/DanEngelbrecht/golongtail/issues/249) --- CHANGELOG.md | 1 + longtailstorelib/fsstore.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eeb58cd..5d579026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## +- **FIXED** Networks share paths that starts with \\ no longer need to be manually escaped (fixes https://github.com/DanEngelbrecht/golongtail/issues/249) - **UPDATED** Update to golang 1.21 - **UPDATED** Update longtaillib to v0.4.1 - **UPDATED** Updated all golang dependencies diff --git a/longtailstorelib/fsstore.go b/longtailstorelib/fsstore.go index 68da455f..8dc0d015 100644 --- a/longtailstorelib/fsstore.go +++ b/longtailstorelib/fsstore.go @@ -31,12 +31,17 @@ type fsBlobObject struct { } const UNCPrefix = "\\\\?\\" +const NetworkPrefix = "\\" func NormalizeFileSystemPath(path string) string { if strings.HasPrefix(path, UNCPrefix) { forwardSlashReplaced := strings.Replace(path, "/", "\\", -1) doubleBackwardRemoved := UNCPrefix + strings.Replace(forwardSlashReplaced[len(UNCPrefix):], "\\\\", "\\", -1) return doubleBackwardRemoved + } else if strings.HasPrefix(path, NetworkPrefix) { + forwardSlashReplaced := strings.Replace(path, "/", "\\", -1) + doubleBackwardRemoved := NetworkPrefix + strings.Replace(forwardSlashReplaced[len(NetworkPrefix):], "\\\\", "\\", -1) + return doubleBackwardRemoved } backwardRemoved := strings.Replace(path, "\\", "/", -1) doubleForwardRemoved := strings.Replace(backwardRemoved, "//", "/", -1)