Cleanup, add ability to skip initial full sync

This commit is contained in:
2025-01-04 03:31:33 +03:00
parent e3f8f7b8c8
commit 9acb554dd4
4 changed files with 28 additions and 23 deletions

View File

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

View File

@@ -15,13 +15,14 @@ const (
)
type Config struct {
SourceDir string
TargetDir string
Mode Mode
Overwrite bool
DirMode uint64
FileMode uint64
Watch bool
SourceDir string
TargetDir string
Mode Mode
Overwrite bool
DirMode uint64
FileMode uint64
Watch bool
SkipFullSync bool
}
func (c *Config) Validate() error {
@@ -37,5 +38,9 @@ func (c *Config) Validate() error {
return fmt.Errorf("invalid mode %s", c.Mode)
}
if c.SkipFullSync && !c.Watch {
return fmt.Errorf("skip full sync and watch disabled — nothing to do")
}
return nil
}