duplicate.go 484 B

123456789101112131415161718192021222324
  1. package site
  2. import (
  3. "github.com/0xJacky/Nginx-UI/internal/helper"
  4. "github.com/0xJacky/Nginx-UI/internal/nginx"
  5. "github.com/pkg/errors"
  6. )
  7. // Duplicate duplicates a site by copying the file
  8. func Duplicate(src, dst string) (err error) {
  9. src = nginx.GetConfPath("sites-available", src)
  10. dst = nginx.GetConfPath("sites-available", dst)
  11. if helper.FileExists(dst) {
  12. return errors.New("file exists")
  13. }
  14. _, err = helper.CopyFile(src, dst)
  15. if err != nil {
  16. return
  17. }
  18. return
  19. }