Skip to content

Commit

Permalink
fine tune
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Apr 9, 2023
1 parent 716bfd5 commit 1ef9c41
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
6 changes: 2 additions & 4 deletions modules/assetfs/layered.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func (l *LayeredFS) ListFiles(name string, fileMode ...bool) ([]string, error) {
return nil, err
}
infos, err := f.Readdir(-1)
_ = f.Close()
if err != nil {
_ = f.Close()
return nil, err
}
for _, info := range infos {
Expand All @@ -133,7 +133,6 @@ func (l *LayeredFS) ListFiles(name string, fileMode ...bool) ([]string, error) {
fileMap[info.Name()] = true
}
}
_ = f.Close()
}
var files []string
for file := range fileMap {
Expand Down Expand Up @@ -164,11 +163,10 @@ func (l *LayeredFS) listAllFiles(layers []*Layer, name string, fileMode ...bool)
return err
}
infos, err := f.Readdir(-1)
_ = f.Close()
if err != nil {
_ = f.Close()
return err
}
_ = f.Close()
for _, info := range infos {
include := false
if len(fileMode) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions modules/templates/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ func Mailer(ctx context.Context) (*texttmpl.Template, *template.Template) {
for _, assetPath := range assetPaths {
content, layerName, err := assetFS.ReadLayeredFile(assetPath)
if err != nil {
log.Warn("Failed to read mail template %s: %v (by %s)", assetPath, err, layerName)
log.Warn("Failed to read mail template %s by %s: %v", assetPath, layerName, err)
continue
}
tmplName := strings.TrimPrefix(strings.TrimSuffix(assetPath, ".tmpl"), "mail/")
log.Debug("Adding mail template %s: %s (by %s)", tmplName, assetPath, layerName)
log.Trace("Adding mail template %s: %s by %s", tmplName, assetPath, layerName)
buildSubjectBodyTemplate(subjectTemplates, bodyTemplates, tmplName, content)
}
}
Expand Down
5 changes: 3 additions & 2 deletions modules/util/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ func Debounce(d time.Duration) func(f func()) {
if db.t != nil {
db.t.Stop()
}
trigger := db.t
db.t = time.AfterFunc(d, func() {
var trigger *time.Timer
trigger = time.AfterFunc(d, func() {
db.mu.Lock()
defer db.mu.Unlock()
if trigger == db.t {
f()
}
})
db.t = trigger
}
}
7 changes: 0 additions & 7 deletions routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ func mustInitCtx(ctx context.Context, fn func(ctx context.Context) error) {
}
}

// InitGitServices init new services for git, this is also called in `contrib/pr/checkout.go`
func InitGitServices() {
setting.LoadSettings()
mustInit(storage.Init)
mustInit(repo_service.Init)
}

func syncAppConfForGit(ctx context.Context) error {
runtimeState := new(system.RuntimeState)
if err := system.AppState.Get(runtimeState); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion routers/install/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func PreloadSettings(ctx context.Context) bool {
}

setting.LoadSettingsForInstall()
svg.Init()
_ = svg.Init()
}

return !setting.InstallLock
Expand Down

0 comments on commit 1ef9c41

Please sign in to comment.