1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-28 09:35:14 +03:00

handle symlinks Fix #238

This commit is contained in:
Zack Scholl 2020-09-03 14:57:09 -07:00
parent ff99b07ef1
commit 555ddec5e3

View File

@ -1088,13 +1088,22 @@ func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error)
return return
} }
} }
emptyFile, errCreate := os.Create(path.Join(fileInfo.FolderRemote, fileInfo.Name)) pathToFile := path.Join(fileInfo.FolderRemote, fileInfo.Name)
if errCreate != nil { if fileInfo.Symlink != "" {
log.Error(errCreate) log.Debug("creating symlink")
err = errCreate err = os.Symlink(fileInfo.Symlink, pathToFile)
return 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 // setup the progressbar
description := fmt.Sprintf("%-*s", c.longestFilename, c.FilesToTransfer[i].Name) description := fmt.Sprintf("%-*s", c.longestFilename, c.FilesToTransfer[i].Name)
if len(c.FilesToTransfer) == 1 { if len(c.FilesToTransfer) == 1 {
@ -1133,7 +1142,7 @@ func (c *Client) updateIfRecipientHasFileInfo() (err error) {
continue continue
} }
fileHash, errHash := utils.HashFile(path.Join(fileInfo.FolderRemote, fileInfo.Name)) 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) err = c.createEmptyFileAndFinish(fileInfo, i)
if err != nil { if err != nil {
return return