From 3c7164846d05d703076c7e32cba2a163cd675111 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 12 Feb 2016 14:53:09 +0100 Subject: [PATCH] Return "No such object in the index" when /rest/db/file gets called on something that doesn't exist Better than the confusing result of getting a blank fileinfo that looks valid apart from being all crap. --- cmd/syncthing/gui.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 79f6585dc..66fb97582 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -615,8 +615,14 @@ func (s *apiService) getDBFile(w http.ResponseWriter, r *http.Request) { qs := r.URL.Query() folder := qs.Get("folder") file := qs.Get("file") - gf, _ := s.model.CurrentGlobalFile(folder, file) - lf, _ := s.model.CurrentFolderFile(folder, file) + gf, gfOk := s.model.CurrentGlobalFile(folder, file) + lf, lfOk := s.model.CurrentFolderFile(folder, file) + + if !(gfOk || lfOk) { + // This file for sure does not exist. + http.Error(w, "No such object in the index", http.StatusNotFound) + return + } av := s.model.Availability(folder, file) sendJSON(w, map[string]interface{}{