Fixed Ctrl-C handling

This commit is contained in:
2026-02-12 03:18:33 +03:00
parent 1b44637606
commit 4f597b2478
5 changed files with 36 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ var (
ErrFilesystem = errors.New("filesystem")
ErrConnectDependencies = errors.New("failed to connect dependencies")
ErrFailedToPrepareDirectories = errors.New("failed to prepare directories")
ErrFailedToGetWaitGroup = errors.New("failed to get global waitgroup")
ErrNoSource = errors.New("source does not exist")
ErrFailedToCleanupDestination = errors.New("failed to clean up destination directory")
ErrFailedToCreateDestinationDirectory = errors.New("failed to create destination directory")

View File

@@ -58,9 +58,14 @@ func (f *FS) Start() error {
return fmt.Errorf("%w: %w (%w)", ErrFilesystem, ErrFailedToPrepareDirectories, err)
}
go func() {
wg := f.app.GetGlobalWaitGroup()
if wg == nil {
return fmt.Errorf("%w: %w (%s)", ErrFilesystem, ErrFailedToGetWaitGroup, "got nil waitgroup")
}
wg.Go(func() {
f.mount()
}()
})
return nil
}

View File

@@ -43,10 +43,6 @@ func (f *FS) mount() {
}
defer server.Unmount()
select {
case <-f.app.Context().Done():
return
default:
server.Wait()
}
<-f.app.Context().Done()
f.app.Logger().Debug("Application context cancelled, unmounting FUSE server...")
}