mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
add zipping to sending
This commit is contained in:
parent
5bf4ff1866
commit
83f199b213
1 changed files with 18 additions and 2 deletions
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/schollz/croc/src/logger"
|
||||
"github.com/schollz/croc/src/models"
|
||||
"github.com/schollz/croc/src/utils"
|
||||
"github.com/schollz/croc/src/zipper"
|
||||
"github.com/schollz/pake"
|
||||
"github.com/schollz/progressbar/v2"
|
||||
"github.com/tscholl2/siec"
|
||||
|
@ -48,10 +49,25 @@ func send(c *websocket.Conn, fname string, codephrase string) (err error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fstats := models.FileStats{fstat.Name(), fstat.Size(), fstat.ModTime(), fstat.IsDir()}
|
||||
fstats := models.FileStats{fstat.Name(), fstat.Size(), fstat.ModTime(), fstat.IsDir(), ""}
|
||||
if fstats.IsDir {
|
||||
// zip the directory
|
||||
|
||||
fstats.DirName, err = zipper.ZipFile(fname, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
f.Close()
|
||||
// reopen file
|
||||
f, err = os.Open(fstats.DirName)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fstat, err := f.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// get new size
|
||||
fstats.Size = fstat.Size()
|
||||
}
|
||||
|
||||
// get ready to generate session key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue