mirror of https://github.com/schollz/croc.git
gather symlink info
This commit is contained in:
parent
26056a8366
commit
ff99b07ef1
|
@ -124,6 +124,7 @@ type FileInfo struct {
|
||||||
ModTime time.Time `json:"m,omitempty"`
|
ModTime time.Time `json:"m,omitempty"`
|
||||||
IsCompressed bool `json:"c,omitempty"`
|
IsCompressed bool `json:"c,omitempty"`
|
||||||
IsEncrypted bool `json:"e,omitempty"`
|
IsEncrypted bool `json:"e,omitempty"`
|
||||||
|
Symlink string `json:"sy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoteFileRequest requests specific bytes
|
// RemoteFileRequest requests specific bytes
|
||||||
|
@ -192,7 +193,7 @@ func (c *Client) sendCollectFiles(options TransferOptions) (err error) {
|
||||||
var folderName string
|
var folderName string
|
||||||
folderName, _ = filepath.Split(fullPath)
|
folderName, _ = filepath.Split(fullPath)
|
||||||
|
|
||||||
fstats, err = os.Stat(fullPath)
|
fstats, err = os.Lstat(fullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -206,6 +207,15 @@ func (c *Client) sendCollectFiles(options TransferOptions) (err error) {
|
||||||
Size: fstats.Size(),
|
Size: fstats.Size(),
|
||||||
ModTime: fstats.ModTime(),
|
ModTime: fstats.ModTime(),
|
||||||
}
|
}
|
||||||
|
if fstats.Mode()&os.ModeSymlink != 0 {
|
||||||
|
log.Debugf("%s is symlink", fstats.Name())
|
||||||
|
c.FilesToTransfer[i].Symlink, err = os.Readlink(pathToFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Debugf("error getting symlink: %s", err.Error())
|
||||||
|
}
|
||||||
|
log.Debugf("%+v", c.FilesToTransfer[i])
|
||||||
|
}
|
||||||
|
|
||||||
c.FilesToTransfer[i].Hash, err = utils.HashFile(fullPath)
|
c.FilesToTransfer[i].Hash, err = utils.HashFile(fullPath)
|
||||||
totalFilesSize += fstats.Size()
|
totalFilesSize += fstats.Size()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue