ipfswatch: fix panic on broken link (#11145)
Some checks failed
CodeQL / codeql (push) Has been cancelled
Docker Check / lint (push) Has been cancelled
Docker Check / build (push) Has been cancelled
Gateway Conformance / gateway-conformance (push) Has been cancelled
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Has been cancelled
Go Build / go-build (push) Has been cancelled
Go Check / go-check (push) Has been cancelled
Go Lint / go-lint (push) Has been cancelled
Go Test / unit-tests (push) Has been cancelled
Go Test / cli-tests (push) Has been cancelled
Go Test / example-tests (push) Has been cancelled
Interop / interop-prep (push) Has been cancelled
Sharness / sharness-test (push) Has been cancelled
Spell Check / spellcheck (push) Has been cancelled
Interop / helia-interop (push) Has been cancelled
Interop / ipfs-webui (push) Has been cancelled

Fix panic when broken link is created in watch directory.

Closes #10017
This commit is contained in:
Andrew Gillis 2026-01-13 20:44:28 -08:00 committed by GitHub
parent 6a595c27a9
commit 4bdc9ad220
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -150,6 +150,7 @@ func run(ipfsPath, watchPath string) error {
log.Printf("received event: %s", e)
isDir, err := IsDirectory(e.Name)
if err != nil {
log.Println(err)
continue
}
switch e.Op {
@ -220,7 +221,7 @@ func addTree(w *fsnotify.Watcher, root string) error {
return filepath.SkipDir
case isDir:
log.Println(path)
if err := w.Add(path); err != nil {
if err = w.Add(path); err != nil {
return err
}
default:
@ -233,7 +234,10 @@ func addTree(w *fsnotify.Watcher, root string) error {
func IsDirectory(path string) (bool, error) {
fileInfo, err := os.Stat(path)
return fileInfo.IsDir(), err
if err != nil {
return false, err
}
return fileInfo.IsDir(), nil
}
func IsHidden(path string) bool {