[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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1c0d590c81
Коммит
7bd18264fd
@@ -674,6 +674,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
c.Err.StatusCode = http.StatusNotFound
|
c.Err.StatusCode = http.StatusNotFound
|
||||||
|
return
|
||||||
}
|
}
|
||||||
defer fileReader.Close()
|
defer fileReader.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -980,5 +980,10 @@ func TestGetPublicFile(t *testing.T) {
|
|||||||
fileInfo, err := th.App.Srv().Store.FileInfo().Get(fileId)
|
fileInfo, err := th.App.Srv().Store.FileInfo().Get(fileId)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Nil(t, th.cleanupTestFile(fileInfo))
|
require.Nil(t, th.cleanupTestFile(fileInfo))
|
||||||
|
|
||||||
th.cleanupTestFile(info)
|
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")
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user