summaryrefslogtreecommitdiffstats
path: root/tools/notes
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2025-10-04 22:44:33 -0700
committerRose Hogenson <rosehogenson@posteo.net>2025-10-04 22:44:33 -0700
commit624985afaaa8b94e4d9685bcdc935d467f9e7060 (patch)
tree7b13e8f4ccf75b6042bebea7fb239570644a216e /tools/notes
parent573601b19c8ae582adcd1a7c4b8c0ebfa4295aed (diff)
downloadroseh.moe-624985afaaa8b94e4d9685bcdc935d467f9e7060.tar.zst
Allow downloading without gob
Diffstat (limited to 'tools/notes')
-rw-r--r--tools/notes/notes.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/notes/notes.go b/tools/notes/notes.go
index 9f190f6..7714a89 100644
--- a/tools/notes/notes.go
+++ b/tools/notes/notes.go
@@ -10,6 +10,7 @@ import (
"io"
"net/http"
"os"
+ "path/filepath"
"time"
"github.com/google/subcommands"
@@ -213,6 +214,7 @@ func (*newCommand) SetFlags(*flag.FlagSet) {}
type createNoteRequestStreamWriter struct {
ctx context.Context
+ fileName string
continuationToken []byte
}
@@ -225,6 +227,7 @@ func (w *createNoteRequestStreamWriter) Write(buf []byte) (int, error) {
for i := 0; i < 3; i++ {
resp, err = createNote(w.ctx, &api.CreateNoteRequest{
ContinuationToken: w.continuationToken,
+ FileName: w.fileName,
Chunk: buf,
More: true,
})
@@ -242,6 +245,7 @@ func (w *createNoteRequestStreamWriter) Write(buf []byte) (int, error) {
if err != nil {
return 0, err
}
+ w.fileName = ""
w.continuationToken = resp.ContinuationToken
return len(buf), nil
}
@@ -252,7 +256,7 @@ func (*newCommand) new(ctx context.Context, fileName string) error {
return err
}
defer f.Close()
- streamWriter := &createNoteRequestStreamWriter{ctx: ctx}
+ streamWriter := &createNoteRequestStreamWriter{ctx: ctx, fileName: filepath.Base(fileName)}
if _, err := io.Copy(streamWriter, f); err != nil {
return err
}