From 903fe1d51a9f716a77dafb877c3ac74839694815 Mon Sep 17 00:00:00 2001 From: vlastahajek Date: Wed, 30 Aug 2017 16:22:25 +0200 Subject: [PATCH] fix: #902,#916 - manipulation of recording path is now more windows friendly --- services/replay/service.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/services/replay/service.go b/services/replay/service.go index 54c9d9076..18fec6137 100644 --- a/services/replay/service.go +++ b/services/replay/service.go @@ -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, @@ -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)), } } @@ -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 {