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
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
- fmt.Fprintf(os.Stderr, nncp.UsageHeader())
- fmt.Fprintf(os.Stderr, "nncp-reass -- reassemble chunked files\n\n")
+ fmt.Fprint(os.Stderr, nncp.UsageHeader())
+ fmt.Fprint(os.Stderr, "nncp-reass -- reassemble chunked files\n\n")
func process(ctx *nncp.Ctx, path string, keep, dryRun, stdout, dumpMeta bool) bool {
fd, err := os.Open(path)
func process(ctx *nncp.Ctx, path string, keep, dryRun, stdout, dumpMeta bool) bool {
fd, err := os.Open(path)
var metaPkt nncp.ChunkedMeta
les := nncp.LEs{{K: "Path", V: path}}
logMsg := func(les nncp.LEs) string {
var metaPkt nncp.ChunkedMeta
les := nncp.LEs{{K: "Path", V: path}}
logMsg := func(les nncp.LEs) string {
}
hsh = nncp.MTHNew(fi.Size(), 0)
if _, err = nncp.CopyProgressed(
}
hsh = nncp.MTHNew(fi.Size(), 0)
if _, err = nncp.CopyProgressed(
- hsh, bufio.NewReader(fd), "check",
+ hsh, bufio.NewReaderSize(fd, nncp.MTHBlockSize), "check",
nncp.LEs{{K: "Pkt", V: chunkPath}, {K: "FullSize", V: fi.Size()}},
ctx.ShowPrgrs,
); err != nil {
log.Fatalln(err)
}
fd.Close()
nncp.LEs{{K: "Pkt", V: chunkPath}, {K: "FullSize", V: fi.Size()}},
ctx.ShowPrgrs,
); err != nil {
log.Fatalln(err)
}
fd.Close()
ctx.LogE(
"reass-chunk",
nncp.LEs{{K: "Path", V: path}, {K: "Chunk", V: chunkNum}},
ctx.LogE(
"reass-chunk",
nncp.LEs{{K: "Path", V: path}, {K: "Chunk", V: chunkNum}},
log.Fatalln("Can not stat file:", err)
}
if _, err = nncp.CopyProgressed(
log.Fatalln("Can not stat file:", err)
}
if _, err = nncp.CopyProgressed(
- dstW, bufio.NewReader(fd), "reass",
+ dstW, bufio.NewReaderSize(fd, nncp.MTHBlockSize), "reass",
nncp.LEs{{K: "Pkt", V: chunkPath}, {K: "FullSize", V: fi.Size()}},
ctx.ShowPrgrs,
); err != nil {
nncp.LEs{{K: "Pkt", V: chunkPath}, {K: "FullSize", V: fi.Size()}},
ctx.ShowPrgrs,
); err != nil {
- if err = tmp.Sync(); err != nil {
- log.Fatalln("Can not sync:", err)
+ if !nncp.NoSync {
+ if err = tmp.Sync(); err != nil {
+ log.Fatalln("Can not sync:", err)
+ }
}
if err = tmp.Close(); err != nil {
log.Fatalln("Can not close:", err)
}
if err = tmp.Close(); err != nil {
log.Fatalln("Can not close:", err)
func findMetas(ctx *nncp.Ctx, dirPath string) []string {
dir, err := os.Open(dirPath)
func findMetas(ctx *nncp.Ctx, dirPath string) []string {
dir, err := os.Open(dirPath)
ctx.LogE("reass", nncp.LEs{{K: "Path", V: dirPath}}, err, logMsg)
return nil
}
ctx.LogE("reass", nncp.LEs{{K: "Path", V: dirPath}}, err, logMsg)
return nil
}