Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: delete resource related file (#1456)

boojack5caa8cdec536
diff --git a/server/resource.go b/server/resource.go
index 78fb1ba9a..39c264ddc 100644
--- a/server/resource.go
+++ b/server/resource.go
@@ -19,7 +19,9 @@ import (
"github.com/pkg/errors"
"github.com/usememos/memos/api"
"github.com/usememos/memos/common"
+ "github.com/usememos/memos/common/log"
"github.com/usememos/memos/plugin/storage/s3"
+ "go.uber.org/zap"
)
const (
@@ -294,6 +296,13 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized")
}
+ if resource.InternalPath != "" {
+ err := os.Remove(resource.InternalPath)
+ if err != nil {
+ log.Warn(fmt.Sprintf("failed to delete local file with path %s", resource.InternalPath), zap.Error(err))
+ }
+ }
+
resourceDelete := &api.ResourceDelete{
ID: resourceID,
}