Add file timestamps

This commit is contained in:
Justin Hawkins 2022-01-26 08:49:54 +10:30
parent 1026cc5dd9
commit 80d23b514c
3 changed files with 13 additions and 7 deletions

View File

@ -59,6 +59,7 @@ func (c *Client) Connect() error {
} }
// now we expect to get stuff back until we don't // now we expect to get stuff back until we don't
numFiles := 0
for { for {
listPacket := secure.PacketListData{} listPacket := secure.PacketListData{}
err := dec.Decode(&listPacket) err := dec.Decode(&listPacket)
@ -68,8 +69,10 @@ func (c *Client) Connect() error {
if err != nil { if err != nil {
panic(err) panic(err)
} }
fmt.Printf("%d: %s (%s)\n", listPacket.Id, listPacket.Kind, humanize.Bytes(uint64(listPacket.FileSize))) fmt.Printf("%d: %s (%s) - %s\n", listPacket.Id, listPacket.Kind, humanize.Bytes(uint64(listPacket.FileSize)), listPacket.Timestamp)
numFiles++
} }
fmt.Printf("total: %d files\n", numFiles)
conn.Close() conn.Close()
log.Debugf("done listing") log.Debugf("done listing")
@ -180,7 +183,7 @@ func (c *Client) connectToServer(op secure.OperationTypeEnum, enc *gob.Encoder,
startPacket := secure.PacketStartRequest{ startPacket := secure.PacketStartRequest{
OperationType: op, OperationType: op,
ClientName: "", ClientName: "",
ProtocolVersion: "1.0", ProtocolVersion: "1.1",
AuthToken: c.authToken, AuthToken: c.authToken,
} }
err := enc.Encode(startPacket) err := enc.Encode(startPacket)

View File

@ -7,6 +7,7 @@ import (
"errors" "errors"
"io" "io"
"net" "net"
"time"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -226,8 +227,9 @@ type PacketReceiveDataNext struct {
} }
type PacketListData struct { type PacketListData struct {
Id uint32 Id uint32
Filename string Filename string
FileSize uint32 FileSize uint32
Kind string Timestamp time.Time
Kind string
} }

View File

@ -108,7 +108,7 @@ func (s *Server) handleConnection(conn *net.TCPConn) {
// tell teh client the dealio // tell teh client the dealio
startResponse := secure.PacketStartResponse{} startResponse := secure.PacketStartResponse{}
if start.ProtocolVersion != "1.0" { if start.ProtocolVersion != "1.1" {
log.Errorf("bad protocol version") log.Errorf("bad protocol version")
startResponse.Response = secure.PacketStartResponseEnumWrongProtocol startResponse.Response = secure.PacketStartResponseEnumWrongProtocol
enc.Encode(startResponse) enc.Encode(startResponse)
@ -307,6 +307,7 @@ func (s *Server) handleConnection(conn *net.TCPConn) {
p.Kind = ngf.Kind p.Kind = ngf.Kind
p.Id = ngf.Id p.Id = ngf.Id
p.Filename = ngf.Filename p.Filename = ngf.Filename
p.Timestamp = ngf.Timestamp
enc.Encode(p) enc.Encode(p)
} }
log.Debugf("done sending list, closing connection") log.Debugf("done sending list, closing connection")