fix(port-forward): clear port file instead of removing it
- Prevent port forwarding loop crash when trying to delete a directly bind mounted file - See https://github.com/qdm12/gluetun/issues/2942#issuecomment-3468510402
This commit is contained in:
@@ -3,7 +3,6 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -61,10 +60,10 @@ func (s *Service) cleanup() (err error) {
|
|||||||
s.ports = nil
|
s.ports = nil
|
||||||
|
|
||||||
filepath := s.settings.Filepath
|
filepath := s.settings.Filepath
|
||||||
s.logger.Info("removing port file " + filepath)
|
s.logger.Info("clearing port file " + filepath)
|
||||||
err = os.Remove(filepath)
|
err = s.writePortForwardedFile(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("removing port file: %w", err)
|
return fmt.Errorf("clearing port file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user