mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 21:30:16 +02:00
starting to work
This commit is contained in:
parent
a66f71ac98
commit
0607514b3b
2 changed files with 9 additions and 1 deletions
|
@ -121,6 +121,7 @@ func send(c *cli.Context) (err error) {
|
||||||
sharedSecret = utils.GetRandomName()
|
sharedSecret = utils.GetRandomName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
haveFolder := false
|
||||||
paths := []string{}
|
paths := []string{}
|
||||||
for _, fname := range fnames {
|
for _, fname := range fnames {
|
||||||
stat, err := os.Stat(fname)
|
stat, err := os.Stat(fname)
|
||||||
|
@ -128,6 +129,7 @@ func send(c *cli.Context) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if stat.IsDir() {
|
if stat.IsDir() {
|
||||||
|
haveFolder = true
|
||||||
err = filepath.Walk(fname,
|
err = filepath.Walk(fname,
|
||||||
func(pathName string, info os.FileInfo, err error) error {
|
func(pathName string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -159,7 +161,7 @@ func send(c *cli.Context) (err error) {
|
||||||
|
|
||||||
err = cr.Send(croc.TransferOptions{
|
err = cr.Send(croc.TransferOptions{
|
||||||
PathToFiles: paths,
|
PathToFiles: paths,
|
||||||
KeepPathInRemote: false, // TODO: add options to change this
|
KeepPathInRemote: haveFolder,
|
||||||
})
|
})
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -147,6 +147,12 @@ func (s *Session) receiveData(pathToFile string, fileSize int64) error {
|
||||||
log.Debugln("Starting to receive data...")
|
log.Debugln("Starting to receive data...")
|
||||||
log.Debugf("receiving %s", pathToFile)
|
log.Debugf("receiving %s", pathToFile)
|
||||||
|
|
||||||
|
folderForFile, _ := filepath.Split(pathToFile)
|
||||||
|
err := os.MkdirAll(folderForFile, os.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// truncate if nessecary
|
// truncate if nessecary
|
||||||
var f *os.File
|
var f *os.File
|
||||||
var errOpen error
|
var errOpen error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue