From ff9a7afe99201eea052f66d308af97b25859ae8b Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 17 Jul 2023 17:47:55 +0800 Subject: [PATCH] Skip unuseful error message in dev mode when watching local filesystem (#25919) Before, in dev mode, there might be some error logs like: ``` 2023/07/17 13:54:51 ...s/assetfs/layered.go:221:WatchLocalChanges() [E] Unable to watch directory .: lstat /data/work/gitea/custom/templates: no such file or directory ``` Because there is no "custom/templates" directory. After: ignore such error, no such error message anymore. --- modules/assetfs/layered.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/assetfs/layered.go b/modules/assetfs/layered.go index e18a13e4aaf..d69732f81be 100644 --- a/modules/assetfs/layered.go +++ b/modules/assetfs/layered.go @@ -217,7 +217,7 @@ func (l *LayeredFS) WatchLocalChanges(ctx context.Context, callback func()) { } layerDirs = append(layerDirs, ".") for _, dir := range layerDirs { - if err = watcher.Add(util.FilePathJoinAbs(layer.localPath, dir)); err != nil { + if err = watcher.Add(util.FilePathJoinAbs(layer.localPath, dir)); err != nil && !os.IsNotExist(err) { log.Error("Unable to watch directory %s: %v", dir, err) } }