mirror of
https://github.com/derfenix/photocatalog.git
synced 2026-03-11 20:46:24 +03:00
Refactoring
This commit is contained in:
@@ -50,17 +50,17 @@ func (a *Application) Start(ctx context.Context, wg *sync.WaitGroup) error {
|
|||||||
org = org.WithOverwrite()
|
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 a.config.Watch {
|
||||||
if err := org.Watch(ctx, wg); err != nil {
|
if err := org.Watch(ctx, wg); err != nil {
|
||||||
return fmt.Errorf("initialize watch: %w", err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ type HardLink struct {
|
|||||||
|
|
||||||
func (h HardLink) PlaceIt(sourcePath, targetPath string, mode os.FileMode) error {
|
func (h HardLink) PlaceIt(sourcePath, targetPath string, mode os.FileMode) error {
|
||||||
if hardLinkNotSupported.Load() {
|
if hardLinkNotSupported.Load() {
|
||||||
if copyErr := (Copy{}).PlaceIt(sourcePath, targetPath, mode); copyErr != nil {
|
return h.fallBack(sourcePath, targetPath, mode)
|
||||||
return copyErr
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Link(sourcePath, targetPath); err != nil {
|
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())
|
log.Println("Create hardlink failed:", err.Error())
|
||||||
hardLinkNotSupported.Store(true)
|
hardLinkNotSupported.Store(true)
|
||||||
|
|
||||||
if copyErr := (Copy{}).PlaceIt(sourcePath, targetPath, mode); copyErr != nil {
|
return h.fallBack(sourcePath, targetPath, mode)
|
||||||
return copyErr
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user