aboutsummaryrefslogtreecommitdiff
path: root/hotline
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2024-04-29 13:02:01 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2024-04-29 16:33:35 -0700
commit4a88189f30efac3cd86159b88c1a316a610e1523 (patch)
treec60b54036edf60f4578cccf5c00d7f25af7484b9 /hotline
parentb51f0536ad15f8a197d41fab60c3b00bd63ee381 (diff)
Make GetFileInfo behavior consistent with official 1.9 server behavior
Diffstat (limited to 'hotline')
-rw-r--r--hotline/transaction_handlers.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go
index 931340e..d86e928 100644
--- a/hotline/transaction_handlers.go
+++ b/hotline/transaction_handlers.go
@@ -390,16 +390,26 @@ func HandleGetFileInfo(cc *ClientConn, t *Transaction) (res []Transaction, err e
return res, fmt.Errorf("invalid filepath encoding: %w", err)
}
- res = append(res, cc.NewReply(t,
+ fields := []Field{
NewField(FieldFileName, []byte(encodedName)),
NewField(FieldFileTypeString, fw.ffo.FlatFileInformationFork.friendlyType()),
NewField(FieldFileCreatorString, fw.ffo.FlatFileInformationFork.friendlyCreator()),
- NewField(FieldFileComment, fw.ffo.FlatFileInformationFork.Comment),
NewField(FieldFileType, fw.ffo.FlatFileInformationFork.TypeSignature),
NewField(FieldFileCreateDate, fw.ffo.FlatFileInformationFork.CreateDate),
NewField(FieldFileModifyDate, fw.ffo.FlatFileInformationFork.ModifyDate),
- NewField(FieldFileSize, fw.totalSize()),
- ))
+ }
+
+ // Include the optional FileComment field if there is a comment.
+ if len(fw.ffo.FlatFileInformationFork.Comment) != 0 {
+ fields = append(fields, NewField(FieldFileComment, fw.ffo.FlatFileInformationFork.Comment))
+ }
+
+ // Include the FileSize field for files.
+ if !bytes.Equal(fw.ffo.FlatFileInformationFork.TypeSignature, []byte{0x66, 0x6c, 0x64, 0x72}) {
+ fields = append(fields, NewField(FieldFileSize, fw.totalSize()))
+ }
+
+ res = append(res, cc.NewReply(t, fields...))
return res, err
}