Refactoring, fix bug

This commit is contained in:
2025-01-07 03:53:28 +03:00
parent e1670934a1
commit 56e826e580
2 changed files with 5 additions and 3 deletions

View File

@@ -14,6 +14,8 @@ const (
ModeMove Mode = "move"
)
var supportedModes = []Mode{ModeHardlink, ModeSymlink, ModeMove, ModeCopy}
type Config struct {
SourceDir string
TargetDir string
@@ -34,8 +36,8 @@ func (c *Config) Validate() error {
return fmt.Errorf("target dir is required")
}
if !slices.Contains([]Mode{ModeHardlink, ModeSymlink, ModeMove, ModeCopy}, c.Mode) {
return fmt.Errorf("invalid mode %s", c.Mode)
if !slices.Contains(supportedModes, c.Mode) {
return fmt.Errorf("invalid mode %s, supported modes: %s", c.Mode, supportedModes)
}
if c.SkipFullSync && !c.Watch {