Skip to content

Commit

Permalink
handle symlinks Fix #238
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Sep 3, 2020
1 parent ff99b07 commit 555ddec
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/croc/croc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,13 +1088,22 @@ func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error)
return
}
}
emptyFile, errCreate := os.Create(path.Join(fileInfo.FolderRemote, fileInfo.Name))
if errCreate != nil {
log.Error(errCreate)
err = errCreate
return
pathToFile := path.Join(fileInfo.FolderRemote, fileInfo.Name)
if fileInfo.Symlink != "" {
log.Debug("creating symlink")
err = os.Symlink(fileInfo.Symlink, pathToFile)
if err != nil {
return
}
} else {
emptyFile, errCreate := os.Create(pathToFile)
if errCreate != nil {
log.Error(errCreate)
err = errCreate
return
}
emptyFile.Close()
}
emptyFile.Close()
// setup the progressbar
description := fmt.Sprintf("%-*s", c.longestFilename, c.FilesToTransfer[i].Name)
if len(c.FilesToTransfer) == 1 {
Expand Down Expand Up @@ -1133,7 +1142,7 @@ func (c *Client) updateIfRecipientHasFileInfo() (err error) {
continue
}
fileHash, errHash := utils.HashFile(path.Join(fileInfo.FolderRemote, fileInfo.Name))
if fileInfo.Size == 0 {
if fileInfo.Size == 0 || fileInfo.Symlink != "" {
err = c.createEmptyFileAndFinish(fileInfo, i)
if err != nil {
return
Expand Down

0 comments on commit 555ddec

Please sign in to comment.