MM-16261 - Store Plugin in File Store (#11511)
* Implemneted saving the plugin bundle on the file store upon plugin upload * Fixed compilation error * Fixed compilation issue * Added deletion from file store upon plugin uninstall * Added condition to delete from store only when exists. Added case of saving the bundle to the store when uploading from url. Added checks in plugin tests * Fixed compilation error * Moved storage of plugin bundle within app/installPlugin * Moved storing to filestore before enabling the plugin * Fixed error handling * Code styling improvements * Minor styling fix
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
b464f31b38
Коммит
859c571558
@@ -6,6 +6,8 @@
|
||||
package api4
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
@@ -124,13 +126,19 @@ func installPluginFromUrl(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Query().Get("force") == "true" {
|
||||
force = true
|
||||
}
|
||||
manifest, unpackErr := c.App.InstallPlugin(resp.Body, force)
|
||||
|
||||
fileBytes, readErr := ioutil.ReadAll(resp.Body)
|
||||
if readErr != nil {
|
||||
c.Err = model.NewAppError("installPluginFromUrl", "api.plugin.install.reading_stream_failed.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
manifest, unpackErr := c.App.InstallPlugin(bytes.NewReader(fileBytes), force)
|
||||
|
||||
if unpackErr != nil {
|
||||
c.Err = unpackErr
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
w.Write([]byte(manifest.ToJson()))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user