Skip to content

Commit

Permalink
path slash separator for OS
Browse files Browse the repository at this point in the history
  • Loading branch information
desistefanova committed Aug 18, 2024
1 parent e5eace7 commit bb567f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/impl/folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"io/fs"
"net/http"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -50,9 +51,11 @@ func GetFoldersHandler(w http.ResponseWriter, r *http.Request) {
userName := result.User
deviceId := result.DeviceId
dirName := filepath.Join(config.UploadDirectory, userName, deviceId)
separator := string(os.PathSeparator)
err := filepath.WalkDir(dirName, func(path string, d fs.DirEntry, err error) error {
if d != nil && d.IsDir() && deviceId != d.Name() {
fld := strings.TrimLeft(strings.Replace(strings.TrimRight(path, "/"), dirName, "", 1), "/")
fld := strings.Replace(strings.TrimRight(path, separator), dirName, "", 1)
fld = strings.TrimLeft(fld, separator)
logger.InfoF("File path %s", path)
logger.InfoF("File path ends with %s", fld)
if len(fld) == 4 {
Expand Down

0 comments on commit bb567f7

Please sign in to comment.