[MM-28945] api4/file: add missing return statement (#15552)

* api4/file: add missing return statement

* api4/file: add a test case for GetPublicFile; request a deleted file

* add missing check

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2020-09-29 10:32:47 +03:00
коммит произвёл GitHub
родитель 1c0d590c81
Коммит 7bd18264fd
2 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@@ -674,6 +674,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) {
if err != nil {
c.Err = err
c.Err.StatusCode = http.StatusNotFound
return
}
defer fileReader.Close()

Просмотреть файл

@@ -980,5 +980,10 @@ func TestGetPublicFile(t *testing.T) {
fileInfo, err := th.App.Srv().Store.FileInfo().Get(fileId)
require.Nil(t, err)
require.Nil(t, th.cleanupTestFile(fileInfo))
th.cleanupTestFile(info)
link = th.App.GeneratePublicLink(Client.Url, info)
resp, err = http.Get(link)
require.Nil(t, err)
require.Equal(t, http.StatusNotFound, resp.StatusCode, "should've failed to get file after it is deleted")
}