lstat_broken.go 738 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (C) 2015 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. // +build linux android
  7. package osutil
  8. import (
  9. "os"
  10. "syscall"
  11. "time"
  12. )
  13. // Lstat is like os.Lstat, except lobotomized for Android. See
  14. // https://forum.syncthing.net/t/2395
  15. func Lstat(name string) (fi os.FileInfo, err error) {
  16. for i := 0; i < 10; i++ { // We have to draw the line somewhere
  17. fi, err = os.Lstat(name)
  18. if err, ok := err.(*os.PathError); ok && err.Err == syscall.EINTR {
  19. time.Sleep(time.Duration(i+1) * time.Millisecond)
  20. continue
  21. }
  22. return
  23. }
  24. return
  25. }