gui: /rest/system/browse with no arguments returns drives on Windows (ref #3201)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3203
This commit is contained in:
Audrius Butkevicius
2016-05-31 19:27:07 +00:00
committed by Jakob Borg
parent 4970bd7f65
commit 1612baca92
3 changed files with 67 additions and 0 deletions

View File

@@ -1173,6 +1173,14 @@ func (s *apiService) getPeerCompletion(w http.ResponseWriter, r *http.Request) {
func (s *apiService) getSystemBrowse(w http.ResponseWriter, r *http.Request) {
qs := r.URL.Query()
current := qs.Get("current")
if current == "" && runtime.GOOS == "windows" {
if drives, err := osutil.GetDriveLetters(); err == nil {
sendJSON(w, drives)
} else {
http.Error(w, err.Error(), 500)
}
return
}
search, _ := osutil.ExpandTilde(current)
pathSeparator := string(os.PathSeparator)
if strings.HasSuffix(current, pathSeparator) && !strings.HasSuffix(search, pathSeparator) {