worked out some bugs in exporting messages, not all in new code - mechanisms will be needed to cope with the bugs in the database
This commit is contained in:
Vendored
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "auto",
|
"mode": "auto",
|
||||||
"program": "${workspaceFolder}",
|
"program": "${workspaceFolder}",
|
||||||
"args": ["-C", "${workspaceFolder}/test.yaml"]
|
"args": ["-C", "${workspaceFolder}/test.yaml", "--buggy-attachments"]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -20,6 +20,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
argparse "github.com/alexflint/go-arg"
|
argparse "github.com/alexflint/go-arg"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,8 +32,9 @@ const AMSTERDAM_COPYRIGHT = "2025-2026"
|
|||||||
|
|
||||||
// AmCLI is the command-line interface arguments structure.
|
// AmCLI is the command-line interface arguments structure.
|
||||||
type AmCLI struct {
|
type AmCLI struct {
|
||||||
ConfigFile string `arg:"-C,--config" help:"Location of the configuration file."`
|
ConfigFile string `arg:"-C,--config" help:"Location of the configuration file."`
|
||||||
DebugPanic bool `arg:"--debug-panic" help:"Development Only - disable Echo panic recovery"`
|
DebugPanic bool `arg:"--debug-panic" help:"Development Only - disable Echo panic recovery"`
|
||||||
|
BuggyAttachments bool `arg:"--buggy-attachments" help:"Some attachments may be buggy - truncate data if necessary"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommandLine is the command-line arguments passed to Amsterdam.
|
// CommandLine is the command-line arguments passed to Amsterdam.
|
||||||
@@ -239,6 +241,10 @@ func parseDataSize(s string) (int32, error) {
|
|||||||
func SetupConfig() {
|
func SetupConfig() {
|
||||||
argparse.MustParse(&CommandLine)
|
argparse.MustParse(&CommandLine)
|
||||||
|
|
||||||
|
if CommandLine.BuggyAttachments {
|
||||||
|
log.Warn("WARNING: --buggy-attachments flag set - NOT recommended for production usage")
|
||||||
|
}
|
||||||
|
|
||||||
if CommandLine.ConfigFile != "" {
|
if CommandLine.ConfigFile != "" {
|
||||||
// load the data and use it to unmarshal the loaded configuration
|
// load the data and use it to unmarshal the loaded configuration
|
||||||
data, err := os.ReadFile(CommandLine.ConfigFile)
|
data, err := os.ReadFile(CommandLine.ConfigFile)
|
||||||
|
|||||||
+14
-2
@@ -16,6 +16,7 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -127,12 +128,23 @@ func (p *PostHeader) AttachmentData(ctx context.Context) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
outdata := make([]byte, 0, datalen)
|
outdata := make([]byte, datalen)
|
||||||
n, err := r.Read(outdata)
|
n, err := r.Read(outdata)
|
||||||
r.Close()
|
r.Close()
|
||||||
|
if err == io.EOF && n == int(datalen) {
|
||||||
|
err = nil // we got everything, this isn't an error
|
||||||
|
}
|
||||||
if err != nil || n < int(datalen) {
|
if err != nil || n < int(datalen) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = errors.New("unable to read entire attachment")
|
if config.CommandLine.BuggyAttachments {
|
||||||
|
log.Warnf("PostHeader.AttachmentData: bugged attachment on post #%d (expected %d bytes, got %d), truncating for retrieval", p.PostId, datalen, n)
|
||||||
|
outdata = outdata[:n]
|
||||||
|
} else {
|
||||||
|
log.Errorf("PostHeader.AttachmentData: unable to read entire attachment to post #%d (expected %d bytes, got %d)", p.PostId, datalen, n)
|
||||||
|
err = errors.New("unable to read entire attachment")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Errorf("PostHeader.AttachmentData: error (%v) reading attachment to post #%d (expected %d bytes, got %d)", err, p.PostId, datalen, n)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ _(italicized items can be deferred)_
|
|||||||
- ~~Custom appearance~~
|
- ~~Custom appearance~~
|
||||||
- ~~Activity reports~~
|
- ~~Activity reports~~
|
||||||
- ~~E-mail~~
|
- ~~E-mail~~
|
||||||
- Export Messages
|
- ~~Export Messages~~
|
||||||
- Import Messages
|
- Import Messages
|
||||||
- Delete Conference
|
- Delete Conference
|
||||||
- ~~Add to Hotlist/Remove from Hotlist~~
|
- ~~Add to Hotlist/Remove from Hotlist~~
|
||||||
|
|||||||
+19
-16
@@ -93,7 +93,9 @@ func VCIFFromPost(ctx context.Context, target *VCIFPost, post *database.PostHead
|
|||||||
|
|
||||||
// Fill in the post text.
|
// Fill in the post text.
|
||||||
target.Text, err = post.Text(ctx)
|
target.Text, err = post.Text(ctx)
|
||||||
if err != nil {
|
if err == database.ErrNoPostData {
|
||||||
|
target.Text = ""
|
||||||
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,24 +115,25 @@ func VCIFFromPost(ctx context.Context, target *VCIFPost, post *database.PostHead
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fill in the attachment data.
|
// Fill in the attachment data.
|
||||||
ainfo, err := post.AttachmentInfo(ctx)
|
target.Attachment = nil
|
||||||
if err != nil {
|
if !post.IsScribbled() {
|
||||||
return err
|
ainfo, err := post.AttachmentInfo(ctx)
|
||||||
}
|
|
||||||
if ainfo != nil {
|
|
||||||
newAttachment := VCIFPostAttachment{
|
|
||||||
Length: int(ainfo.Length),
|
|
||||||
MIMEType: ainfo.MIMEType,
|
|
||||||
Filename: ainfo.Filename,
|
|
||||||
}
|
|
||||||
data, err := post.AttachmentData(ctx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
newAttachment.Base64Data = base64.StdEncoding.EncodeToString(data)
|
if ainfo != nil {
|
||||||
target.Attachment = &newAttachment
|
newAttachment := VCIFPostAttachment{
|
||||||
} else {
|
Length: int(ainfo.Length),
|
||||||
target.Attachment = nil
|
MIMEType: ainfo.MIMEType,
|
||||||
|
Filename: ainfo.Filename,
|
||||||
|
}
|
||||||
|
data, err := post.AttachmentData(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
newAttachment.Base64Data = base64.StdEncoding.EncodeToString(data)
|
||||||
|
target.Attachment = &newAttachment
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in the rest of the data that can't fail.
|
// Fill in the rest of the data that can't fail.
|
||||||
|
|||||||
Reference in New Issue
Block a user