1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +02:00

Fix MM-40428 (#1926)

This commit is contained in:
Hossein 2021-12-10 08:28:52 -05:00 committed by GitHub
parent 87daacceca
commit 199da41f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package app
import (
"path/filepath"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/focalboard/server/services/notify"
"github.com/mattermost/focalboard/server/services/store"
@ -124,6 +126,20 @@ func (a *App) DeleteBlock(c store.Container, blockID string, modifiedBy string)
return err
}
if block.Type == model.TypeImage {
fileName, fileIDExists := block.Fields["fileId"]
if fileName, fileIDIsString := fileName.(string); fileIDExists && fileIDIsString {
filePath := filepath.Join(block.WorkspaceID, block.RootID, fileName)
err = a.filesBackend.RemoveFile(filePath)
if err != nil {
a.logger.Error("Error deleting image file",
mlog.String("FilePath", filePath),
mlog.Err(err))
}
}
}
a.wsAdapter.BroadcastBlockDelete(c.WorkspaceID, blockID, block.ParentID)
a.metrics.IncrementBlocksDeleted(1)
go func() {

View File

@ -20,6 +20,7 @@ const (
TypeView = "view"
TypeText = "text"
TypeComment = "comment"
TypeImage = "image"
)
func (bt BlockType) String() string {
@ -39,6 +40,8 @@ func BlockTypeFromString(s string) (BlockType, error) {
return TypeText, nil
case "comment":
return TypeComment, nil
case "image":
return TypeImage, nil
}
return TypeUnknown, ErrInvalidBlockType{s}
}