initFileInfo initializes file info
()
| 352 | |
| 353 | // initFileInfo initializes file info |
| 354 | func (fn *Node) initFileInfo() error { |
| 355 | ls, err := os.Lstat(string(fn.Filepath)) |
| 356 | if err != nil { |
| 357 | return err |
| 358 | } |
| 359 | if ls.Mode()&os.ModeSymlink != 0 { |
| 360 | effpath, err := filepath.EvalSymlinks(string(fn.Filepath)) |
| 361 | if err != nil { |
| 362 | // this happens too often for links -- skip |
| 363 | // log.Printf("filetree.Node Path: %v could not be opened -- error: %v\n", fn.Filepath, err) |
| 364 | return err |
| 365 | } |
| 366 | fn.Filepath = core.Filename(effpath) |
| 367 | } |
| 368 | |
| 369 | err = fn.Info.InitFile(string(fn.Filepath)) |
| 370 | if err != nil { |
| 371 | emsg := fmt.Errorf("filetree.Node InitFileInfo Path %q: Error: %v", fn.Filepath, err) |
| 372 | log.Println(emsg) |
| 373 | return emsg |
| 374 | } |
| 375 | repo, rnode := fn.Repo() |
| 376 | if repo != nil { |
| 377 | if fn.IsDir() { |
| 378 | fn.Info.VCS = vcs.Stored // always |
| 379 | } else { |
| 380 | rstat := rnode.repoFiles.Status(repo, string(fn.Filepath)) |
| 381 | if rstat != fn.Info.VCS { |
| 382 | fn.Info.VCS = rstat |
| 383 | fn.NeedsRender() |
| 384 | } |
| 385 | } |
| 386 | } else { |
| 387 | fn.Info.VCS = vcs.Stored |
| 388 | } |
| 389 | return nil |
| 390 | } |
| 391 | |
| 392 | // SelectedFunc runs the given function on all selected nodes in reverse order. |
| 393 | func (fn *Node) SelectedFunc(fun func(n *Node)) { |