diff --git a/internal/cmd_publish.go b/internal/cmd_publish.go index a908b8d..35516f6 100644 --- a/internal/cmd_publish.go +++ b/internal/cmd_publish.go @@ -66,7 +66,7 @@ func publishCmd(ctx context.Context) error { // publish item if err := publish(ctx, msg); err != nil { - return errors.Wrap(err, "failed to publish") + return errors.Wrapf(err, "failed to publish id: %d", msg.ChannelMessages.ID) } _, err := tbl.UPDATE().SET(tbl.Published.SET(Bool(true))).WHERE(tbl.ID.EQ(Int64(msg.ChannelMessages.ID))).ExecContext(ctx, db) @@ -110,6 +110,10 @@ func publish(_ context.Context, msg publishMsg) error { continue } + if file == "" { + continue + } + filepath := filepath.Join(config.C.Output, file) b, err := os.ReadFile(filepath) if err != nil { diff --git a/pkg/memos/memos.go b/pkg/memos/memos.go index b267968..8eed044 100644 --- a/pkg/memos/memos.go +++ b/pkg/memos/memos.go @@ -60,6 +60,10 @@ func Post(pd PostData) error { return errors.New("post memo failed, body: " + resp.String()) } + if len(pd.Resources) == 0 { + return nil + } + type Resources struct { Resources []Resource `json:"resources"` }