aboutsummaryrefslogtreecommitdiff
path: root/internal/service/git.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/service/git.go')
-rw-r--r--internal/service/git.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/internal/service/git.go b/internal/service/git.go
index d56c96b..830f602 100644
--- a/internal/service/git.go
+++ b/internal/service/git.go
@@ -93,7 +93,10 @@ func MirrorGit(dst *internal.URL, src *internal.URL, description string) error {
return fmt.Errorf("'%s' scheme not supported", dst.Scheme)
}
- if _, err := os.Stat(dst.Path); os.IsNotExist(err) {
+ entries, err := os.ReadDir(dst.Path)
+ if err != nil && !os.IsNotExist(err) {
+ return fmt.Errorf("creating directory '%s': %w", dst.Path, err)
+ } else if os.IsNotExist(err) || len(entries) == 0 {
err = os.MkdirAll(path.Join(dst.Path, ".."), 0750)
if err != nil {
return fmt.Errorf("creating new mirror: %w", err)
@@ -117,11 +120,6 @@ func MirrorGit(dst *internal.URL, src *internal.URL, description string) error {
}
}
- err := setDescription(dst.Path, description)
- if err != nil {
- return err
- }
-
err = setRemoteOrigin(dst.Path, src)
if err != nil {
return err
@@ -140,5 +138,10 @@ func MirrorGit(dst *internal.URL, src *internal.URL, description string) error {
return fmt.Errorf("fetching project: %s", err)
}
+ err = setDescription(dst.Path, description)
+ if err != nil {
+ return err
+ }
+
return nil
}