Scrap IsSymlink for native support on Go 1.4
Obviously needs Go 1.4 to go back in. I am still open to doing fix-up's on rescan interval on Windows, which would still allow getting rid of all the Windows code. Frankly, we could just defer creations of links (like we defer deletions of files) in hopes that the target gets created, and if it doesn't, well tough luck, you'll get a file symlink. To be honest, nobody would even notice this 'issue' as I am sure nobody on Windows uses symlinks. But at the same time, this ugly code is hidden away in some creppy file in it's own module far far away, and the interface that it exports is fine'ish, so I wouldn't mind keeping it as it is.
This commit is contained in:
@@ -373,12 +373,11 @@ func (p *Puller) handleDir(file protocol.FileInfo) {
|
||||
}
|
||||
|
||||
info, err := os.Lstat(realName)
|
||||
isLink, _ := symlinks.IsSymlink(realName)
|
||||
switch {
|
||||
// There is already something under that name, but it's a file/link.
|
||||
// Most likely a file/link is getting replaced with a directory.
|
||||
// Remove the file/link and fall through to directory creation.
|
||||
case isLink || (err == nil && !info.IsDir()):
|
||||
case err == nil && (!info.IsDir() || info.Mode()&os.ModeSymlink != 0):
|
||||
err = osutil.InWritableDir(os.Remove, realName)
|
||||
if err != nil {
|
||||
l.Infof("Puller (folder %q, dir %q): %v", p.folder, file.Name, err)
|
||||
@@ -795,8 +794,7 @@ func (p *Puller) performFinish(state *sharedPullerState) {
|
||||
// If the target path is a symlink or a directory, we cannot copy
|
||||
// over it, hence remove it before proceeding.
|
||||
stat, err := os.Lstat(state.realName)
|
||||
isLink, _ := symlinks.IsSymlink(state.realName)
|
||||
if isLink || (err == nil && stat.IsDir()) {
|
||||
if err == nil && (stat.IsDir() || stat.Mode()&os.ModeSymlink != 0) {
|
||||
osutil.InWritableDir(os.Remove, state.realName)
|
||||
}
|
||||
// Replace the original content with the new one
|
||||
|
||||
Reference in New Issue
Block a user