Show DCC send filesize
This commit is contained in:
parent
45f8795fad
commit
02e9df865e
File diff suppressed because one or more lines are too long
|
@ -147,12 +147,12 @@ export default function handleSocket({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
dcc_send({ network, from, filename, url }) {
|
dcc_send({ network, from, filename, size, url }) {
|
||||||
const networkName = getState().networks[network]?.name || network;
|
const networkName = getState().networks[network]?.name || network;
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
openModal('confirm', {
|
openModal('confirm', {
|
||||||
question: `${from} on ${networkName} is sending you: ${filename}`,
|
question: `${from} on ${networkName} is sending you (${size}): ${filename}`,
|
||||||
confirmation: 'Download',
|
confirmation: 'Download',
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
|
|
|
@ -112,10 +112,10 @@ func (pack *DCCSend) Download(w io.Writer, progress chan DownloadProgress) error
|
||||||
percentage := 100 * (float64(totalBytes) / float64(pack.Length))
|
percentage := 100 * (float64(totalBytes) / float64(pack.Length))
|
||||||
|
|
||||||
progress <- DownloadProgress{
|
progress <- DownloadProgress{
|
||||||
Speed: humanReadableByteCount(averageSpeed, true),
|
Speed: formatByteCount(averageSpeed, true),
|
||||||
PercCompletion: percentage,
|
PercCompletion: percentage,
|
||||||
BytesRemaining: humanReadableByteCount(bytesRemaining, false),
|
BytesRemaining: formatByteCount(bytesRemaining, false),
|
||||||
BytesCompleted: humanReadableByteCount(float64(totalBytes), false),
|
BytesCompleted: formatByteCount(float64(totalBytes), false),
|
||||||
SecondsElapsed: secondsSince(start),
|
SecondsElapsed: secondsSince(start),
|
||||||
SecondsToGo: bytesRemaining / averageSpeed,
|
SecondsToGo: bytesRemaining / averageSpeed,
|
||||||
File: pack.File,
|
File: pack.File,
|
||||||
|
@ -127,7 +127,7 @@ func (pack *DCCSend) Download(w io.Writer, progress chan DownloadProgress) error
|
||||||
if progress != nil {
|
if progress != nil {
|
||||||
progress <- DownloadProgress{
|
progress <- DownloadProgress{
|
||||||
PercCompletion: 100,
|
PercCompletion: 100,
|
||||||
BytesCompleted: humanReadableByteCount(float64(totalBytes), false),
|
BytesCompleted: formatByteCount(float64(totalBytes), false),
|
||||||
SecondsElapsed: secondsSince(start),
|
SecondsElapsed: secondsSince(start),
|
||||||
File: pack.File,
|
File: pack.File,
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,10 @@ func (pack *DCCSend) Download(w io.Writer, progress chan DownloadProgress) error
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pack *DCCSend) Size() string {
|
||||||
|
return formatByteCount(float64(pack.Length), false)
|
||||||
|
}
|
||||||
|
|
||||||
type DownloadProgress struct {
|
type DownloadProgress struct {
|
||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
Error error `json:"error"`
|
Error error `json:"error"`
|
||||||
|
@ -172,7 +176,7 @@ const (
|
||||||
gibibyte
|
gibibyte
|
||||||
)
|
)
|
||||||
|
|
||||||
func humanReadableByteCount(b float64, speed bool) string {
|
func formatByteCount(b float64, speed bool) string {
|
||||||
unit := ""
|
unit := ""
|
||||||
value := b
|
value := b
|
||||||
|
|
||||||
|
|
|
@ -496,6 +496,7 @@ func (i *ircHandler) receiveDCCSend(pack *irc.DCCSend, msg *irc.Message) {
|
||||||
Network: i.client.Host(),
|
Network: i.client.Host(),
|
||||||
From: msg.Sender,
|
From: msg.Sender,
|
||||||
Filename: pack.File,
|
Filename: pack.File,
|
||||||
|
Size: pack.Size(),
|
||||||
URL: fmt.Sprintf("%s://%s/downloads/%s/%s",
|
URL: fmt.Sprintf("%s://%s/downloads/%s/%s",
|
||||||
i.state.String("scheme"), i.state.String("host"), i.state.user.Username, pack.File),
|
i.state.String("scheme"), i.state.String("host"), i.state.user.Username, pack.File),
|
||||||
})
|
})
|
||||||
|
|
|
@ -218,6 +218,7 @@ type DCCSend struct {
|
||||||
Network string
|
Network string
|
||||||
From string
|
From string
|
||||||
Filename string
|
Filename string
|
||||||
|
Size string
|
||||||
URL string
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue