Skip to content

Commit

Permalink
Networks share paths that starts with \\ no longer need to be manuall…
Browse files Browse the repository at this point in the history
…y escaped (#250)

- **FIXED** Networks share paths that starts with \\ no longer need to be manually escaped (fixes #249)
  • Loading branch information
DanEngelbrecht authored Mar 3, 2024
1 parent 6f36a27 commit 3b418bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions longtailstorelib/fsstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b418bc

Please sign in to comment.