Skip to content

Commit

Permalink
fix: influxdata#902,influxdata#916 - manipulation of recording path i…
Browse files Browse the repository at this point in the history
…s now more windows friendly
  • Loading branch information
vlastahajek authored and floriandudouet-swisscom committed Jun 12, 2018
1 parent 4e8d130 commit e6b4149
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions services/replay/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (s *Service) syncRecordingMetadata() error {
}
dataUrl := url.URL{
Scheme: "file",
Path: filepath.Join(s.saveDir, info.Name()),
Path: filepath.ToSlash(filepath.Join(s.saveDir, info.Name())),
}
recording := Recording{
ID: id,
Expand Down Expand Up @@ -578,7 +578,7 @@ func (s *Service) handleDeleteRecording(w http.ResponseWriter, r *http.Request)
func (s *Service) dataURLFromID(id, ext string) url.URL {
return url.URL{
Scheme: "file",
Path: filepath.Join(s.saveDir, id+ext),
Path: filepath.ToSlash(filepath.Join(s.saveDir, id+ext)),
}
}

Expand Down Expand Up @@ -1637,12 +1637,18 @@ func parseDataSourceURL(rawurl string) (DataSource, error) {
}
switch u.Scheme {
case "file":
return fileSource(u.Path), nil
return fileSource(getFilePathFromUrl(u)), nil
default:
return nil, fmt.Errorf("unsupported data source scheme %s", u.Scheme)
}
}

//getFilePathFromUrl restores filesystem path from file URL
func getFilePathFromUrl(url *url.URL) string {
//Host part on windows contains drive, on non windows it is empty
return url.Host + filepath.FromSlash(url.Path)
}

func (s fileSource) Size() (int64, error) {
info, err := os.Stat(string(s))
if err != nil {
Expand Down

0 comments on commit e6b4149

Please sign in to comment.