| 468 | } |
| 469 | |
| 470 | func sameFile(f1, f2 *os.File) (bool, error) { |
| 471 | fi1, err := f1.Stat() |
| 472 | if err != nil { |
| 473 | return false, fmt.Errorf("failed to get fileInfo of the first file (%s): %w", f1.Name(), err) |
| 474 | } |
| 475 | fi2, err := f2.Stat() |
| 476 | if err != nil { |
| 477 | return false, fmt.Errorf("failed to get fileInfo of the second file (%s): %w", f2.Name(), err) |
| 478 | } |
| 479 | |
| 480 | return os.SameFile(fi1, fi2), nil |
| 481 | } |
| 482 | |
| 483 | // CopyFile copies the entire database to file at the given path. |
| 484 | // A reader transaction is maintained during the copy so it is safe to continue |