Refactoring

This commit is contained in:
2025-01-07 03:44:24 +03:00
parent 62daa023f5
commit e1670934a1
2 changed files with 15 additions and 14 deletions

View File

@@ -50,17 +50,17 @@ func (a *Application) Start(ctx context.Context, wg *sync.WaitGroup) error {
org = org.WithOverwrite()
}
if !a.config.SkipFullSync {
if err := org.FullSync(ctx); err != nil {
return fmt.Errorf("full sync: %w", err)
}
}
if a.config.Watch {
if err := org.Watch(ctx, wg); err != nil {
return fmt.Errorf("initialize watch: %w", err)
}
}
if !a.config.SkipFullSync {
if err := org.FullSync(ctx); err != nil {
return fmt.Errorf("full sync: %w", err)
}
}
return nil
}

View File

@@ -13,9 +13,7 @@ type HardLink struct {
func (h HardLink) PlaceIt(sourcePath, targetPath string, mode os.FileMode) error {
if hardLinkNotSupported.Load() {
if copyErr := (Copy{}).PlaceIt(sourcePath, targetPath, mode); copyErr != nil {
return copyErr
}
return h.fallBack(sourcePath, targetPath, mode)
}
if err := os.Link(sourcePath, targetPath); err != nil {
@@ -26,12 +24,15 @@ func (h HardLink) PlaceIt(sourcePath, targetPath string, mode os.FileMode) error
log.Println("Create hardlink failed:", err.Error())
hardLinkNotSupported.Store(true)
if copyErr := (Copy{}).PlaceIt(sourcePath, targetPath, mode); copyErr != nil {
return copyErr
}
return nil
return h.fallBack(sourcePath, targetPath, mode)
}
return nil
}
func (h HardLink) fallBack(sourcePath string, targetPath string, mode os.FileMode) error {
if copyErr := (Copy{}).PlaceIt(sourcePath, targetPath, mode); copyErr != nil {
return copyErr
}
return nil
}