diff --git a/server/router/api/v1/memo_attachment_service.go b/server/router/api/v1/memo_attachment_service.go index 153f1aa80..d9aa0a3ee 100644 --- a/server/router/api/v1/memo_attachment_service.go +++ b/server/router/api/v1/memo_attachment_service.go @@ -76,6 +76,9 @@ func (s *APIV1Service) SetMemoAttachments(ctx context.Context, request *v1pb.Set if err != nil { return nil, status.Errorf(codes.Internal, "failed to get attachment: %v", err) } + if tempAttachment == nil { + return nil, status.Errorf(codes.NotFound, "attachment not found: %s", attachmentUID) + } updatedTs := time.Now().Unix() + int64(index) if err := s.Store.UpdateAttachment(ctx, &store.UpdateAttachment{ ID: tempAttachment.ID, diff --git a/store/attachment.go b/store/attachment.go index cd3ac2a16..f9897d08e 100644 --- a/store/attachment.go +++ b/store/attachment.go @@ -129,7 +129,7 @@ func (s *Store) DeleteAttachment(ctx context.Context, delete *DeleteAttachment) p = filepath.Join(s.profile.Data, p) } err := os.Remove(p) - if err != nil { + if err != nil && !os.IsNotExist(err) { return errors.Wrap(err, "failed to delete local file") } return nil