зеркало из https://github.com/golang/dep.git
Merge the latest strip codes fromt the master
This commit is contained in:
Родитель
345fa0e2f5
Коммит
82b5519797
|
@ -21,8 +21,8 @@ func stripVendor(path string, info os.FileInfo, err error) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// If the file is a symlink to a directory, delete the symlink.
|
||||
if (info.Mode() & os.ModeSymlink) != 0 {
|
||||
// If the file is a symlink to a directory, delete the symlink.
|
||||
if (info.Mode() & os.ModeSymlink) != 0 {
|
||||
if realInfo, err := os.Stat(path); err == nil && realInfo.IsDir() {
|
||||
return os.Remove(path)
|
||||
}
|
||||
|
|
|
@ -14,34 +14,37 @@ func stripVendor(path string, info os.FileInfo, err error) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if info.Name() != "vendor" {
|
||||
if info.Name() != "vendor" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := os.Lstat(path); err == nil {
|
||||
symlink := (info.Mode() & os.ModeSymlink) != 0
|
||||
dir := info.IsDir()
|
||||
if _, err := os.Lstat(path); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch {
|
||||
case symlink && dir:
|
||||
// This could be a windows junction directory. Support for these in the
|
||||
// standard library is spotty, and we could easily delete an important
|
||||
// folder if we called os.Remove or os.RemoveAll. Just skip these.
|
||||
//
|
||||
// TODO: If we could distinguish between junctions and Windows symlinks,
|
||||
// we might be able to safely delete symlinks, even though junctions are
|
||||
// dangerous.
|
||||
return filepath.SkipDir
|
||||
symlink := (info.Mode() & os.ModeSymlink) != 0
|
||||
dir := info.IsDir()
|
||||
|
||||
case symlink:
|
||||
if realInfo, err := os.Stat(path); err == nil && realInfo.IsDir() {
|
||||
return os.Remove(path)
|
||||
}
|
||||
switch {
|
||||
case symlink && dir:
|
||||
// This could be a windows junction directory. Support for these in the
|
||||
// standard library is spotty, and we could easily delete an important
|
||||
// folder if we called os.Remove or os.RemoveAll. Just skip these.
|
||||
//
|
||||
// TODO: If we could distinguish between junctions and Windows symlinks,
|
||||
// we might be able to safely delete symlinks, even though junctions are
|
||||
// dangerous.
|
||||
return filepath.SkipDir
|
||||
|
||||
case dir:
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
return err
|
||||
}
|
||||
case symlink:
|
||||
if realInfo, err := os.Stat(path); err == nil && realInfo.IsDir() {
|
||||
return os.Remove(path)
|
||||
}
|
||||
|
||||
case dir:
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
return err
|
||||
}
|
||||
return filepath.SkipDir
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче