mirror of https://github.com/schollz/croc.git
remove dirs after encoding
This commit is contained in:
parent
04dc07913e
commit
9746014f0b
19
connect.go
19
connect.go
|
@ -117,6 +117,7 @@ func NewConnection(config *AppConfig) (*Connection, error) {
|
||||||
fmt.Println("Compressing folder...")
|
fmt.Println("Compressing folder...")
|
||||||
|
|
||||||
// we "tarify" the file
|
// we "tarify" the file
|
||||||
|
log.Debugf("compressing %s to %s", config.File, path.Base(config.File)+".tar")
|
||||||
err = tarinator.Tarinate([]string{config.File}, path.Base(config.File)+".tar")
|
err = tarinator.Tarinate([]string{config.File}, path.Base(config.File)+".tar")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c, err
|
return c, err
|
||||||
|
@ -131,6 +132,7 @@ func NewConnection(config *AppConfig) (*Connection, error) {
|
||||||
c.File.Path = path.Dir(config.File)
|
c.File.Path = path.Dir(config.File)
|
||||||
c.File.Size, _ = FileSize(config.File)
|
c.File.Size, _ = FileSize(config.File)
|
||||||
c.IsSender = true
|
c.IsSender = true
|
||||||
|
log.Debugf("file: %+v", c.File)
|
||||||
} else {
|
} else {
|
||||||
c.IsSender = false
|
c.IsSender = false
|
||||||
c.AskPath = config.PathSpec
|
c.AskPath = config.PathSpec
|
||||||
|
@ -220,14 +222,6 @@ func (c *Connection) Run() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove compressed archive
|
|
||||||
if c.File.IsDir {
|
|
||||||
log.Debug("removing archive: " + c.File.Name)
|
|
||||||
if err := os.Remove(c.File.Name); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Server != "localhost" {
|
if c.Server != "localhost" {
|
||||||
// broadcast local connection from sender
|
// broadcast local connection from sender
|
||||||
log.Debug("settings payload to ", c.Code)
|
log.Debug("settings payload to ", c.Code)
|
||||||
|
@ -416,7 +410,7 @@ func (c *Connection) runClient(serverName string) error {
|
||||||
c.File.IsEncrypted = false
|
c.File.IsEncrypted = false
|
||||||
} else {
|
} else {
|
||||||
// encrypt
|
// encrypt
|
||||||
log.Debugf("encrypting file with passphrase [%s]", passphraseString)
|
log.Debugf("encrypting %s with passphrase [%s]", path.Join(c.File.Path, c.File.Name), passphraseString)
|
||||||
if err := EncryptFile(path.Join(c.File.Path, c.File.Name), c.File.Name+".enc", passphraseString); err != nil {
|
if err := EncryptFile(path.Join(c.File.Path, c.File.Name), c.File.Name+".enc", passphraseString); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -431,6 +425,13 @@ func (c *Connection) runClient(serverName string) error {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove compressed archive
|
||||||
|
if c.File.IsDir {
|
||||||
|
log.Debug("removing archive: " + c.File.Name)
|
||||||
|
if err := os.Remove(c.File.Name); err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
c.encryptedPassword = base64.StdEncoding.EncodeToString(encryptedPassword)
|
c.encryptedPassword = base64.StdEncoding.EncodeToString(encryptedPassword)
|
||||||
}
|
}
|
||||||
log.Debugf("[%d] waiting for 0 thread to encrypt", id)
|
log.Debugf("[%d] waiting for 0 thread to encrypt", id)
|
||||||
|
|
Loading…
Reference in New Issue