This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
}
filename := filepath.Join(dir.Name(), fiInt.Name())
sds["file"] = filename
+ delete(sds, "size")
fd, err := os.Open(filename)
if err != nil {
ctx.LogE("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{"err": err}), "open")
fd.Close()
continue
}
+ sds["size"] = strconv.FormatInt(fiInt.Size(), 10)
+ if !ctx.IsEnoughSpace(fiInt.Size()) {
+ ctx.LogE("nncp-xfer", sds, "is not enough space")
+ fd.Close()
+ continue
+ }
fd.Seek(0, 0)
tmp, err := ctx.NewTmpFileWHash()
if err != nil {
log.Fatalln(err)
}
- copied, err := io.Copy(tmp.W, bufio.NewReader(fd))
- if err != nil {
+ if _, err = io.CopyN(tmp.W, bufio.NewReader(fd), fiInt.Size()); err != nil {
ctx.LogE("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{"err": err}), "copy")
isBad = true
fd.Close()
)); err != nil {
log.Fatalln(err)
}
- ctx.LogI("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{
- "size": strconv.FormatInt(copied, 10),
- }), "")
+ ctx.LogI("nncp-xfer", sds, "")
if !*keep {
if err = os.Remove(filename); err != nil {
ctx.LogE("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{"err": err}), "remove")